我已经使用了admob sdk并添加了外部jar.In xml我指定了
<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">
<TextView android:id="@+id/headerfield"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ListView android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<com.google.ads.AdView
android:id="@+id/ad"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="Publisher Id"
ads:loadAdOnCreate="true" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
表现
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation"/>
Run Code Online (Sandbox Code Playgroud)
但在图形模式下它给我一个错误日志:
com.google.ads.AdView - the following class could not be instantiated.
Run Code Online (Sandbox Code Playgroud)
程序里面显示它
您必须在AndroidManifest.xml中使用configChanges声明AdActivity.
从文档中,您需要在活动中包含其他configChanges(假设您使用的是4.3.1或更高版本):
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
Run Code Online (Sandbox Code Playgroud)
如果遇到无法识别screenSize和smallestScreenSize的问题,则必须编译aganist Android 3.2或更高版本.查看此迁移博客文章,了解有关将4.1.1升级到更新版本的更多信息(同样适用于迁移到6.0.0).
| 归档时间: |
|
| 查看次数: |
10143 次 |
| 最近记录: |