Getting java.lang.NoClassDefFoundError for admob interstitials on some devices

129 views
Skip to first unread message

Alexander Rieger

unread,
Mar 28, 2019, 2:53:46 PM3/28/19
to google-adm...@googlegroups.com
Play Store reports crashes on newest AdMob on some devices with Android 9:

    java.lang.NoClassDefFoundError: 
      at jq.b (com.google.android.gms.dynamite_adsdynamite@15090081@15.0.90 (100400-231259764):3)
      at jp.a (com.google.android.gms.dynamite_adsdynamite@15090081@15.0.90 (100400-231259764):3)
      at jr.a (com.google.android.gms.dynamite_adsdynamite@15090081@15.0.90 (100400-231259764):19)
      at com.google.android.gms.ads.internal.util.ar.a (com.google.android.gms.dynamite_adsdynamite@15090081@15.0.90 (100400-231259764):15)
      at iu.a (com.google.android.gms.dynamite_adsdynamite@15090081@15.0.90 (100400-231259764):20)
      at iu.run (com.google.android.gms.dynamite_adsdynamite@15090081@15.0.90 (100400-231259764):8)
    Caused by: java.lang.ClassNotFoundException: 
      at dalvik.system.BaseDexClassLoader.findClass (BaseDexClassLoader.java:134)
      at java.lang.ClassLoader.loadClass (ClassLoader.java:379)
      at ad.loadClass (com.google.android.gms.dynamite_dynamiteloader@1509...@15.0.90 (100400-231259764):4)
      at java.lang.ClassLoader.loadClass (ClassLoader.java:312)

I have upgraded my gradle file to use the newest targetSdkVersion 28 and newest AdMob SDK 17.2.0. But I had conflict problems with different versions of com.android.support libraries. I was able to compile properly by "forcing" com.android.support libraries in version 28.0.0. Maybe this is causing the issue? I am not doing anything fancy, just including admob, facebook, firebase, ... The same app code works without crashes for older targetSdkVersion.

Also I noticed there is the possibility to add the ads over firebase which uses different lib implementation 'com.google.firebase:firebase-ads:17.2.0' and different classes and requries different data in manifest.

Here is my gradle file:

    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 28
        buildToolsVersion '28.0.3'
        defaultConfig {
            minSdkVersion 16
            targetSdkVersion 28
            versionCode 373
            versionName "4.0.6"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
        flavorDimensions "tier"
        productFlavors {
           playStoreFree {
                ...
                dimension "tier"
            }
    
    repositories {
        mavenCentral()
        maven {
            url "https://maven.google.com"
        }
    }
    dependencies {
        implementation fileTree(include: ['*.jar'], dir: 'libs')
        implementation project(':SliderPreference')
        implementation 'com.android.support:customtabs:28.0.0'
        implementation 'com.android.support:animated-vector-drawable:28.0.0'
        implementation 'com.android.support:cardview-v7:28.0.0'
        implementation 'com.android.support:gridlayout-v7:28.0.0'
        implementation 'com.android.support:recyclerview-v7:28.0.0'
        implementation 'com.android.support:appcompat-v7:28.0.0'
        implementation 'com.android.support:support-v4:28.0.0'
        implementation 'com.google.android.gms:play-services-ads:17.2.0'
        implementation 'com.google.android.gms:play-services-analytics:16.0.8'
        implementation 'com.google.firebase:firebase-core:16.0.8'
        implementation 'com.anjlab.android.iab.v3:library:1.0.44'
        implementation 'com.facebook.android:facebook-android-sdk:4.31.0'
        implementation 'com.android.support:recyclerview-v7:28.0.0'
    }
    
    apply plugin: 'com.google.gms.google-services'

In Manifest I have 

    <application ...
            <meta-data
                android:name="com.google.android.gms.ads.AD_MANAGER_APP"
                android:value="true"/>
    ...

Main activity:

    InterstitialAd mInterstitialAd;
    
    @Override
    protected void onPostCreate(Bundle savedInstanceState) {
    MobileAds.initialize(context, BuildConfig.AD_APP_ID);
    MobileAds.setAppMuted(true);
    
    mInterstitialAd = new InterstitialAd (this);
    mInterstitialAd.setAdUnitId(BuildConfig.AD_UNIT_ID);
    
    mInterstitialAd.setAdListener(new AdListener() {
    @Override
    public void onAdFailedToLoad(int errorCode) {
    Log.d("AD", "onAdFailedToLoad: "+String.valueOf(errorCode));
    super.onAdFailedToLoad(errorCode);
    }
    
    @Override
    public void onAdLoaded() {
    Log.d("AD", "onAdLoaded: ");
    super.onAdLoaded();
    }
    
    @Override
    public void onAdClosed() {
    requestNewInterstitial();
    }
    });
    requestNewInterstitial();
    }
    }
   
   
    private void requestNewInterstitial() {
            AdRequest adRequest = new AdRequest.Builder().build();
            mInterstitialAd.loadAd(adRequest);
    }

mobileadssdk...@google.com

unread,
Mar 28, 2019, 5:07:01 PM3/28/19
to Alexander Rieger, Google Mobile Ads SDK Developers
Hello Alexander,

Thanks for reaching out to us. Our team has a fix in place for this issue. The fix should be available in the future releases of the SDK. Please keep an eye on our release history page for more updates.

Regards,
Deepika Uragayala
Mobile Ads SDK Team
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+ page:
    http://googleadsdeveloper.blogspot.com
    https://plus.google.com/115658573333388777174/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

On 03/28/19 14:53:45 alexander...@gmail.com wrote:
Play Store reports crashes on newest AdMob on some devices:

--

---
You received this message because you are subscribed to the Google Groups "Google Mobile Ads SDK Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-admob-ads-sdk+unsub...@googlegroups.com.
To post to this group, send email to google-admob-ads-sdk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-admob-ads-sdk/f9566415-a932-4608-8320-404587876009%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages