Admob广告没有显示出来

7
我有一个关于Admob不显示广告的问题...
这是LogCat:
WARN/AdMobSDK(502): Ignoring requestFreshAd() because we are requesting an ad right now already.
INFO/AdMobSDK(502): No fill.  Server replied that no ads are available (1164ms)
INFO/AdMobSDK(502): No fill.  Server replied that no ads are available (846ms)

我曾尝试过测试模式、非测试模式、模拟器、真实手机等多种方式,但从未看到任何显示内容。然而,我在Admob统计数据中收到了请求和打印信息,就好像它曾经工作过一样...
据我所知,我已经按照Admob Android SDK的要求进行了所有操作...唯一可能导致问题的原因,我认为是我正在使用带有ScrollView的选项卡布局,然后是一个RelativeLayout,在其中广告显示...
以下是选项卡布局的示例:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:myapp="http://schemas.android.com/apk/res/com.xxx.xxx"
    android:id="@+id/tababout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#FF000000">
<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#FF000000"
    android:padding="10px">

    <ImageView
        android:id="@+id/label_img"
        android:src="@drawable/about_header"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:adjustViewBounds="true"
        android:scaleType="centerInside" />

    <TextView android:id="@+id/label_know_more_desc"
        style="@style/Desc"
        android:layout_below="@id/label_img"
        android:text="@string/tab_about_know_more_desc" />

    <Button android:id="@+id/bt_know_more"
        style="@style/Button"
        android:gravity="center_vertical|center_horizontal"
        android:layout_below="@id/label_know_more_desc"
        android:text="@string/tab_about_know_more_bt" />

    <com.admob.android.ads.AdView android:id="@+id/ad" android:layout_width="fill_parent" android:layout_height="wrap_content" myapp:backgroundColor="#000000" myapp:primaryTextColor="#FFFFFF" myapp:secondaryTextColor="#CCCCCC" />
</RelativeLayout>
</ScrollView>

这里是main.xml文件,不过我觉得你可能不需要它:

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FF000000">

<LinearLayout
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <TabWidget
        android:id="@android:id/tabs"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />

    <FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="#FF000000"
        android:paddingTop="5px">

    </FrameLayout>
</LinearLayout>
</TabHost>

我在Admob ads will not display when placed inside a tabview中读到,问题可能是我加入的10像素填充,但即使我禁用它,也不起作用。

我甚至尝试将xmlns:myapp移动到RelativeLayout中,但显然没有改变任何东西....

此外,我已经进行了第一次实时广告请求超过24小时了...

编辑

好的,现在我有所进展,我已经成功显示测试广告(我的setTestDevices太晚了,在onCreate代码中我将其提前到了第一行),但没有真正的广告...我漏掉了什么吗?我显然注释了setTestDevices这一行,没有广告显示出来

编辑2

好的,我添加了两个内部广告(我已经启用了内部广告,但没有设置内部广告),突然间广告开始在我的应用程序上显示出来(不仅仅是内部广告)。

我想所有这些都让它工作了?! :)

谢谢大家!

2个回答

5
您没有在RelativeLayout中定位广告(需要使用layout_above或layout_below等来指定放置位置)。
此外,Admob有一个最小尺寸,您可能希望确保与之匹配,我认为至少高度为48dip,不确定水平方向是多少。
最后,我不知道您想要放置广告的位置,但在主框架布局中放置可能更有意义。我的应用程序底部有一个填充区域,我用于广告视图。
编辑:如果您的应用程序是公共的,请检查广告收入。Android 2.3之前允许广告隐藏在视图后面并仍然注册点击。我的广告甚至在任何人看到之前就已经获得了初始的1美元。

此外,AdMob 报告中存在请求,但没有视图/印象点击。 - Bruno Bernardino
<com.admob.android.ads.AdView
android:id="@+id/ad" android:layout_width="fill_parent" android:layout_height="50dip"
myapp:backgroundColor="#000000" myapp:primaryTextColor="#FFFFFF" myapp:secondaryTextColor="#CCCCCC" android:layout_gravity="center_horizontal|top" /> 这是一个程序相关的内容,其中包含了一些Android布局的代码。
- HaMMeReD
AdManager.setTestDevices( new String[] {
AdManager.TEST_EMULATOR, // Android 模拟器 "MyKey", // } );
- HaMMeReD
真正的广告并不总是能够100%地投放成功,可能需要几天时间才能提高您的请求速率。 - HaMMeReD
我有一个关于广告的问题:http://stackoverflow.com/questions/36389729/ads-are-loading-but-not-showing - Ruchir Baronia
显示剩余9条评论

0
另一个AdMob广告无法显示的原因是您没有声明AdActivity,当用户点击广告时,它将显示广告。如果在AndroidManifest.xml中没有声明AdActivity,则不会看到广告。但是,如果声明了AdActivity,则广告将显示出来。
...AndroidManifest.xml...
<!--  AdMob -->
<activity android:name="com.google.ads.AdActivity"
          android:configChanges="keyboard|keyboardHidden|orientation"/>

这个问题涉及到旧的添加AdMob的方式,该方式不使用或需要AdActivity。 - Kenton Price
我已经完成了所有的事情,但在运行时广告仍然不可见。我为adView提供的区域被留空,我已经给出了背景属性,但它仍然不可见,请帮忙。 - Hardik Vora
我有一个关于广告的问题:http://stackoverflow.com/questions/36389729/ads-are-loading-but-not-showing - Ruchir Baronia

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接