我遇到 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 统计信息上打印,就像它曾经工作过一样。 ..
AFAIK,我在 Admob Android SDK 中做了所有事情......唯一可能导致任何问题的原因,恕我直言,我正在使用带 ScrollView 的选项卡式布局,然后是广告所在的相对布局显示...
这是一个标签布局的示例:
<?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问题可能是我输入的 10px 填充,但即使我禁用它,它也不起作用。
我什至尝试将 xmlns:myapp 移动到 RelativeLayout,但显然没有改变任何东西....
此外,我在 24 小时前发出了我的第一个实时广告请求...
编辑
好吧,现在我有所进展,我已经设法让测试广告出现(我的 setTestDevices 在 onCreate 代码中为时已晚,我将其推到了第一行),但不是真正的广告......我错过了什么吗?我显然注释掉了 setTestDevices 行,没有广告出现
编辑 2
好吧,我添加了两个内部广告(我已经启用了内部广告,但没有设置内部广告),突然广告开始在我的应用程序上展示(不仅仅是内部广告)。
我想一切都让它起作用了?! :)
谢谢大家!
最佳答案
您没有将广告放置在 RelativeLayout 中(它们需要 layout_above 或 layout_below 或其他任何内容来指定放置它们的位置)。
还有一个您可能希望确保匹配的 admob 最小尺寸,我认为它至少像 48dip 高度,不确定水平是多少。
最后,我不知道您要将广告放在哪里,但它可能在您的主框架布局中更有意义,我在我的应用程序底部有一个用于广告 View 的填充.
编辑:如果您的应用是公开的,还要检查广告收入。 Android pre 2.3 允许广告隐藏在 View 后面并仍然记录点击。实际上,在我的广告被任何人看到之前,我就赚到了最初的 1 美元。
关于android - Admob 广告未显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4338081/