[英]AdMob not showing in webview
我正在尝试在Webview中添加AdMob,但效果不佳。在我的main.xml中,我这样写:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="vertical" >
<WebView
android:id="@+id/webview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<com.google.ads.AdView android:id="@+id/ad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="1234567890"
ads:loadAdOnCreate="true"/>
</LinearLayout>
并且在最主要的地方我添加了:
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
当我运行该应用程序时,横幅未显示,并且onFailedToReceiveAd(Invalid Ad request.)
说: onFailedToReceiveAd(Invalid Ad request.)
我认为问题是ID,但我不明白我必须写哪个ID! 我在“ AdMob控制台”中的ID仅带有数字,而不是a14f3ed10a5e4eb
编辑:我试着写:
ca-app-pub-****************/**********
*是数字。 标语出现,但几秒钟后消失。
您应该使用的Admob AdUnitId如下所示:
ca-app-pub-****************/**********
所以您走在正确的轨道上。
你会得到
onFailedToReceiveAd(Invalid Ad request.)
没有可显示的广告时。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.