【发布时间】:2012-02-11 10:27:06
【问题描述】:
我正在我的 android 应用程序的活动中添加 admob adview :
我的代码是:
在 xml 文件中:
<Linearlayout
>
<Button />
<Button />
<com.google.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res/com.sos.emergency"
android:id="@+id/adView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
ads:adSize="BANNER"
ads:adUnitId="publisherid" />
</Linearlayout>
在我的活动中:
AdView adview = (AdView)findViewById(R.id.adView);
adview.loadAd(new AdRequest());
adview.setAdListener(this);
现在我收到以下错误:
Logcat:
02-13 12:03:42.784: E/Ads(271): The android:configChanges value of the com.google.ads.AdActivity must include screenLayout.
02-13 12:03:42.784: E/Ads(271): The android:configChanges value of the com.google.ads.AdActivity must include uiMode.
02-13 12:03:42.784: E/Ads(271): The android:configChanges value of the com.google.ads.AdActivity must include screenSize.
02-13 12:03:42.784: E/Ads(271): The android:configChanges value of the com.google.ads.AdActivity must include smallestScreenSize.
02-13 12:03:42.784: E/Ads(271): You must have AdActivity declared in AndroidManifest.xml with configChanges.
在我的清单文件中,我添加了以下内容:
<activity
android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation" />
请告诉我需要在哪里编辑代码以在我的应用程序上显示广告。
请看它正在显示的 adview 的屏幕截图
您必须在 AndroidManifest.xml 中声明 AdActivity 配置更改
【问题讨论】:
-
为什么是空按钮?其次,您是否在这里查看过它是如何完成的code.google.com/mobile/ads/docs/android/banner_xml.html
-
按钮在原始 xml 文件中具有有效代码我只是在这里将它们发布为空白。我遵循该链接它的示例项目工作我只实现了该链接之后的所有内容,但它显示上述错误
-
你是否也在manifest文件中添加了uses-permission android:name="android.permission.INTERNET?
-
是的,我已经添加了权限
-
您对清单有必要的权限吗?