我使用了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>清单
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation"/>但在图形模式下,它会给我一个错误日志:
com.google.ads.AdView - the following class could not be instantiated. 在程序内部它的展示
您必须使用configChanges在AndroidManifest.xml中声明AdActivity。
发布于 2012-05-04 23:38:27
在documentation中,您需要在活动中包含额外的configChanges (假设您使用的是4.3.1或更高版本):
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>如果你遇到screenSize和smallestScreenSize不能被识别的问题,你将不得不编译aganist Android3.2或更高版本。有关从4.1.1升级到新版本的更多信息,请查看此migration blog post (同样适用于升级到6.0.0 )。
发布于 2012-05-04 19:26:03
你也导出了AdMob库了吗?
转至“项目属性”>“Java生成路径”>“排序并导出”
检查您的admob.jar旁边的小方框是否已选中;如果未选中,请执行此操作。
发布于 2015-07-01 23:57:03
如果有人还在查看这个线程-检查你渲染视图的API级别是否低于17。对我来说,它在17下起作用。你可以使用图形布局上方的小droid来更改它。
https://stackoverflow.com/questions/10447822
复制相似问题