我正在完美工作的android应用程序中集成admob。我设法让我的果冻豆(4.1.2)手机正常工作,但我的蜂窝平板电脑(3.2)上的应用程序崩溃了,并显示
java.lang.NoClassDefFoundError:android.net.http.HttpResponseCache
不确定是否相关,但在我的清单文件中,我已经设置了minSdkVersion="9"
我似乎在谷歌上找不到相关的问题。以前有人见过这个吗?原因可能是什么?
edit:libs文件夹中没有任何文件。一切都是用渐变设置的。
我的清单文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="foo.bar.results"
android:versionCode="6"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="19" />
<application
android:icon="@drawable/bar"
android:label="@string/app_name" >
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<activity
android:name=".bar"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="@android:style/Theme.Translucent" />
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</manifest>
这似乎是(另一个),但在Google Play服务中。我们在安卓3.2上有176个关于这个问题的崩溃报告,所以问题不是你的代码。
以下是Google AdMob论坛上报道的问题:http://goo.gl/hNdiVo
这似乎是一个从9月25日开始的bug。谷歌承诺将在下周内进行更新以解决这个问题。
总而言之,这归结为android文档中的一个错误。Android SDK中的HttpResponseCache表示它在API 13中可用,但似乎API 13实际上并不支持HttpResponceCache,而是你必须转到API 14级才能获得对它的支持。因此,有人在没有正确检查的情况下发布了API 13的版本更改,依赖于Android SDK文档的正确性。
就目前而言,最好的做法是这样做:
try {
adView.loadAd(builder.build());
} catch (NoClassDefFoundError ex) {}
只需从Android SDK Manager更新您的google play服务。之后重新启动IDE,并清理项目。它有效。