Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

admob: app crashes on android 3.2

I am integrating admob in my perfectly working android app. I managed to get things to work on my Jelly Bean (4.1.2) phone, but the app crashed on my honeycomb tablet (3.2) with the message

java.lang.NoClassDefFoundError: android.net.http.HttpResponseCache

Not sure if relevant but in my manifest file I have set my minSdkVersion="9"

I can not seem to find related issues on Google. Has anyone seen this before? What could be the cause?

edit: there are no files in the libs folder. Everything is set up using gradle.

My manifest file:

<?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>
like image 382
bolvo Avatar asked Sep 25 '14 11:09

bolvo


2 Answers

This seems to be (yet another) but in the Google Play Services. We have 176 crash reports on Android 3.2 for this issue so it is not your code that is the problem.

Here is the issue reported in the Google AdMob forum: http://goo.gl/hNdiVo

like image 51
Christer Nordvik Avatar answered Nov 18 '22 10:11

Christer Nordvik


This seems to be a bug that started for a number of people on September 25th. Google has promised that an update will be coming within the next week to fix this problem.

Bottom line, this comes down to a mistake in the android documents. HttpResponseCache in the Android SDK says it is available in API 13, but it seems that API 13 doesn't actually support HttpResponseCache, rather that you have to go to API level 14 to get support for it. So someone released a build change for API 13 without checking it properly, relying on the Android SDK documents to be correct.

For the time being, the best thing to do is to do something like this:

try {
    adView.loadAd(builder.build());
} catch (NoClassDefFoundError ex) {}
like image 35
PearsonArtPhoto Avatar answered Nov 18 '22 10:11

PearsonArtPhoto