Admob广告未出现在我的应用中

时间:2012-12-11 21:30:03

标签: android admob

Admob广告没有出现在我的Android应用中..我使用XML方法实现了admob代码。虽然添加没有出现,但它正在向admob发送请求..(8个请求,100%填充率)。我错过了什么?以及如何在adob广告的XML实现中启用测试模式?

这是我的主要xml文件:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/ScrollView01"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@layout/back2"
        android:orientation="vertical"
        android:padding="30dip" >

        <com.google.ads.AdView
            xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
            android:id="@+id/adView1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            ads:adSize="BANNER"
            ads:adUnitId="AdMob ID"
            ads:loadAdOnCreate="true"
            ads:testDevices="TEST_EMULATOR" />

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="60dp"
            android:text="@string/hello"
            android:textSize="15sp" />

        <Button
            android:id="@+id/button1"
            android:layout_width="fill_parent"
            android:layout_height="60dp"
            android:layout_marginTop="50dp"
            android:background="@color/buttonc1"
            android:text="@string/tutorials"
            android:textSize="21sp" />

        <Button
            android:id="@+id/button2"
            android:layout_width="fill_parent"
            android:layout_height="60dp"
            android:layout_marginTop="30dp"
            android:background="@color/buttonc3"
            android:text="@string/themes"
            android:textSize="21sp" />

        <Button
            android:id="@+id/button3"
            android:layout_width="fill_parent"
            android:layout_height="60dp"
            android:layout_marginTop="30dp"
            android:background="@color/buttonc2"
            android:text="@string/gadgets"
            android:textSize="21sp" />

        <Button
            android:id="@+id/button4"
            android:layout_width="fill_parent"
            android:layout_height="60dp"
            android:layout_marginTop="30dp"
            android:background="@color/buttonc4"
            android:text="@string/networking"
            android:textSize="21sp" />

        <Button
            android:id="@+id/button5"
            android:layout_width="fill_parent"
            android:layout_height="60dp"
            android:layout_marginTop="30dp"
            android:background="@layout/button5"
            android:text="@string/win8index"
            android:textColor="#D5D5D5"
            android:textSize="21sp" />
    </LinearLayout>

</ScrollView>

这是manifest.xml文件

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="org.core.mywindows8"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="org.core.mywindows8.Corefile"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".Contenturl"
            android:label="My Windows 8" >
        </activity>
        <activity
            android:name=".Tutorial"
            android:label="Tutorial Categories" >
        </activity>
        <activity
            android:name=".MainActivity"
            android:label="General Troubleshoot" >
        </activity>
        <activity
            android:name=".Myfeed"
            android:label="Tutorial Categories" >
        </activity>
        <activity
            android:name=".MyWindows"
            android:label="My Windows 8" >
        </activity>
        <activity
            android:name=".Topic"
            android:label="Tutorial Categories" >
        </activity>
        <activity
            android:name=".ActivityNet"
            android:label="Networking and Internet" >
        </activity>
        <activity
            android:name=".Appear"
            android:label="Windows 8 Customization Guide" >
        </activity>
        <activity
            android:name=".HD"
            android:label="Hardware and Drivers" >
        </activity>
        <activity
            android:name=".Index"
            android:label="Windows 8 Master Index" >
        </activity>
        <activity
            android:name=".Inter"
            android:label="Networking Articles" >
        </activity>
        <activity
            android:name=".Short"
            android:label="Shortcut and Context Menu" >
        </activity>
        <activity
            android:name=".StartSc"
            android:label="Taskbar and Start Screen" >
        </activity>
        <activity
            android:name=".Tab"
            android:label="Windows 8 Tablet" >
        </activity>
        <activity
            android:name=".UA"
            android:label="Windows 8 User Account" >
        </activity>
        <activity
            android:name=".Update"
            android:label="Windows 8 Updates and Gadgets" >
        </activity>
        <activity
            android:name=".WinTheme"
            android:label="Windows 8 Themes" >
        </activity>
        <activity
            android:name=".MainActivity1"
            android:label="System and Security" >
        </activity>
        <activity
            android:name="com.google.ads.AdActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
    </application>

</manifest>

1 个答案:

答案 0 :(得分:2)

xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"AdView放在一起,然后从ListView中删除。 (见下文)不要忘记清理你的项目。

另外,从xmlns:android="http://schemas.android.com/apk/res/android"删除LinearLayout

您没有看到广告,因为您没有为广告留出足够的空间而阻止展示,您应该看到此消息。

  

W / Ads(363):没有足够的空间来展示广告!想要:&lt; 480,75&gt;,有:&lt; 390,1073741823&gt;

要查看广告,请提供更多空间。试试这样的事情

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/ScrollView01"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:paddingBottom="30dip"
        android:paddingTop="30dip" >

        <com.google.ads.AdView
            xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
            android:id="@+id/adView1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            ads:adSize="BANNER"
            ads:adUnitId="Your Admob ID"
            ads:loadAdOnCreate="true"
            ads:testDevices="TEST_EMULATOR" />

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:padding="30dip" >

            <!-- Your TextView and Buttons go here -->

        </LinearLayout>
    </LinearLayout>
</ScrollView>

您可以在上面看到这一点,但要在模拟器中放入测试模式,请使用testDevices XML字段。

<com.google.ads.AdView
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:id="@+id/adView1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    ads:adSize="BANNER"
    ads:adUnitId="your id"
    ads:testDevices="TEST_EMULATOR"
    ads:loadAdOnCreate="true" />

添加真实设备,将手机插入计算机并在手机上运行应用。您将在LogCat中看到您的电话ID。会说些绿色的东西。

您可以像这样添加其他真实设备

ads:testDevices="TEST_EMULATOR, 123356r6xcfgxtysd, 456r4y6rfghghsfgd"