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
}
}
flavorDimensions "tier"
productFlavors {
playStoreFree {
...
dimension "tier"
}
repositories {
mavenCentral()
maven {
}
}
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.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);
}