AdMob的广告显示不出来 [英] admob ads doesn't show up
本文介绍了AdMob的广告显示不出来的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我做了一个简单的应用程序,并在里面添加了一个广告,但它并没有在设备中显示出来。
和有我的code没有错误:
XML页面:
< RelativeLayout的的xmlns:机器人=http://schemas.android.com/apk/res/android
的xmlns:广告=http://schemas.android.com/apk/res-auto
的xmlns:工具=http://schemas.android.com/tools
机器人:ID =@ + ID / RelativeLayout1
机器人:layout_width =match_parent
机器人:layout_height =match_parent
工具:上下文=。MainActivity
>
< com.google.android.gms.ads.AdView
的xmlns:程序=http://schemas.android.com/apk/libs/com.google.ads
机器人:ID =@ + ID / AD浏览报
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignParentTop =真
机器人:layout_centerHorizontal =真
机器人:layout_marginTop =66dp
广告:adSize =大旗
广告:adUnitId =ad_ip>
< /com.google.android.gms.ads.AdView>
< / RelativeLayout的>
清单文件:
<使用-权限的Android:名称=android.permission.INTERNET对/>
<使用-权限的Android:名称=android.permission.ACCESS_NETWORK_STATE/>
<使用-权限的Android:名称=com.google.android.gms.permission.ACTIVITY_RECOGNITION>< /使用-许可>
&所述;元数据
机器人:名称=com.google.android.gms.version
机器人:值=4.3.23/>
<活动机器人:名称=com.google.android.gms.ads.AdActivity
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
解决方案
我认为这个问题是在这里
< com.google.android.gms.ads.AdView
的xmlns:程序=http://schemas.android.com/apk/libs/com.google.ads
机器人:ID =@ + ID / AD浏览报
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignParentTop =真
机器人:layout_centerHorizontal =真
机器人:layout_marginTop =66dp
广告:adSize =大旗
广告:adUnitId =ad_ip>
1)xmlns属性应该是这样的,在我的情况下,我已经放在XML文件的根标签。
的xmlns:广告=http://schemas.android.com/apk/res-auto
2)检查,你给AdMob提供的账户的实际adUnitId。
希望这会帮助你,如果有进一步的问题,你可以问。
I made a simple app and added inside it an ad but it doesn't show up in the device.
and there is no errors in my code:
xml page:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
>
<com.google.android.gms.ads.AdView
xmlns:app="http://schemas.android.com/apk/libs/com.google.ads"
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="66dp"
ads:adSize="BANNER"
ads:adUnitId="ad_ip" >
</com.google.android.gms.ads.AdView>
</RelativeLayout>
manifest file:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.google.android.gms.permission.ACTIVITY_RECOGNITION" ></uses-permission>
<meta-data
android:name="com.google.android.gms.version"
android:value="4.3.23" />
<activity android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
解决方案
I think the problem is here
<com.google.android.gms.ads.AdView
xmlns:app="http://schemas.android.com/apk/libs/com.google.ads"
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="66dp"
ads:adSize="BANNER"
ads:adUnitId="ad_ip" >
1) The xmlns attribute should be like this and in my case I have placed in the root tag of xml file.
xmlns:ads="http://schemas.android.com/apk/res-auto"
2) Check, you have given the actual adUnitId from admob account.
Hope this will help you, if any further problems, you can ask.
这篇关于AdMob的广告显示不出来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文