【问题标题】:Admob on android : missing xml attributeandroid 上的 Admob:缺少 xml 属性
【发布时间】: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?
  • 是的,我已经添加了权限
  • 您对清单有必要的权限吗?

标签: android admob


【解决方案1】:

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

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

另外,如果您这样做并且没有在您的project.properties 文件中设置目标(可能需要设置target=android-13 或更高版本,假设您拥有 3.2 或更高版本的 Android SDK)。

在博文here 中找到此信息。

【讨论】:

  • 你能告诉我如何刷新 adview 上的广告我在我的 adview 上添加了ads:refreshInterval="12",但它没有刷新 adview 中的广告
  • 我收到此错误 String types not allowed (at 'configChanges' with value 'keyboard|keyboardHidden|orientation| screenLayout|uiMode|screenSize|smallestScreenSize')
猜你喜欢
  • 1970-01-01
  • 2011-11-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-04-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多