2

I seem to be running into an issue where only release builds crash with the error java.lang.NoClassDefFoundError: Failed resolution of: Lretrofit2/Retrofit$Builder; The class is irrelevant because it has not resolved other classes too in the release build. However, this does not appear on Debug builds which makes no sense at all. I have found that when I include these two dependencies:

implementation 'com.google.android.gms:play-services-ads:12.0.0'
implementation 'com.google.ads.interactivemedia.v3:interactivemedia:3.8.5'

the app crashes. However, when I exclude one of them, then the release builds work. Has anyone encountered this before?

The build config looks like this:

compileSdkVersion 26
buildToolsVersion 26.0.1

defaultConfig {
    applicationId "xxxx"
    minSdkVersion 21
    targetSdkVersion 27
    versionName project.rootProject.version.toString()
    multiDexEnabled true
    vectorDrawables.useSupportLibrary = true
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        signingConfig xxxx
    }
}
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
blackpanther
  • 10,998
  • 11
  • 48
  • 78

1 Answers1

0

Update your gradle

targetSdkVersion 27,

compileSdkVersion 27, and

buildtoolsVersion to 27.0.1 or remove it (leave it as default. gradle will always look for the latest within this version 27)

The above solved my problem too. Although, i don't use multiDexEnabled true as i see no reason why when i have google play service library included.

Try removing multiDexEnabled true and re-build gradle.

Unless your are class extending Application class.Then you can use multiDexEnable true

@Override
protected void attachBaseContext(Context context) {
    super.attachBaseContext(context);
    MultiDex.install(this);
}

check this question for possible solution

olajide
  • 972
  • 1
  • 13
  • 26