Android上的Admob:缺少xml属性

时间:2012-02-11 10:27:07

标签: android admob

我在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" />

请告诉我在哪里需要编辑代码以在我的应用程序上显示广告。

请参阅正在显示的广告的屏幕截图

  

您必须在AndroidManifest.xml中声明AdActivity   configChange

ScreenShot

1 个答案:

答案 0 :(得分:2)

您使用的是新版本的AdMob SDK(4.3.1)吗?如果你是,你的活动可能会在configChanges下面有一些额外的项目,如下所示:

<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>

此外,如果您执行此操作但未在project.properties文件中设置目标(假设您的Android SDK为3.2或更高版本,则可能需要设置target=android-13或更高版本)。

在博文here中找到此信息。