0

Admob 广告没有出现在我的 android 应用程序中。我已经使用 XML 方法实现了 admob 代码。虽然没有出现添加,但它正在向 admob 发送请求 ..(8 个请求,填充率为 100%)。我错过了什么?以及如何在 admob 广告的 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>
4

1 回答 1

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):没有足够的空间来展示广告!想要: <480, 75>, 有: <390, 1073741823>

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

<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>

您可以在上面看到这一点,但要在您的模拟器中设置测试模式,请使用testDevicesXML 字段。

<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"
于 2012-12-11T22:04:11.700 回答