19

I'm having this error whilst compiling Instrumentation tests.

Error:com.android.builder.dexing.DexArchiveBuilderException: Failed to process /Users/rafaelruizmunoz/SourceTree/Weather/app/build/intermediates/transforms/desugar/androidTest/debug/1.jar

Error:com.android.builder.dexing.DexArchiveBuilderException: Error while dexing org/assertj/core/api/LongPredicateAssert.class

Error:com.android.dx.cf.code.SimException: default or static interface method used without --min-sdk-version >= 24

I tried to enable/disable multiDexEnabled in my build.gradle but nothing helped.

My android of build.gradle:

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.**.weather"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        targetCompatibility 1.8
        sourceCompatibility 1.8
    }
}
Community
  • 1
  • 1
Rafael Ruiz Muñoz
  • 5,333
  • 6
  • 46
  • 92

6 Answers6

27

In gradle.properties add android.enableD8=true This should work.

Please note that there is a known bug when you export and upload the apk to play store with d8 enable. The app will not run on some devices when downloaded from play store.

https://issuetracker.google.com/issues/64740479

Sunny
  • 14,522
  • 15
  • 84
  • 129
  • 1
    Well as I understand, problem is not with deploying apk to Play Store, it's rather about resulting app won't run on some devices. This is why they don't recommend publishing app compiled with D8 – user1209216 Nov 06 '17 at 13:33
  • 1
    For those interested in knowing what android.enableD8 = true means, read here : https://android-developers.googleblog.com/2017/08/next-generation-dex-compiler-now-in.html – vepzfe Feb 08 '18 at 19:52
5

I just have the same error for me, it was because of okhttp and I downgrade implementation of it form:

to this:

implementation "com.squareup.okhttp3:okhttp:3.12.1"
Zoe
  • 27,060
  • 21
  • 118
  • 148
AmirahmadAdibi
  • 358
  • 3
  • 9
4

If you're using guava, tou can try to upgrade it to the latest android-specific build

implementation 'com.google.guava:guava:23.0-android'

This fixed the error for me when I was using the non-android guava build.

Diego Plentz
  • 6,760
  • 3
  • 30
  • 31
4

With latest android studio 3.2 and gradle, we can also resolve it via

implementation 'com.android.support:multidex:1.0.3' in app build.gradle
Zoe
  • 27,060
  • 21
  • 118
  • 148
manish
  • 41
  • 2
0

I have had the same issue and I resolved it by disabling the advanced profiling in run configuration.

Edit Configurations -> app -> Profiling -> Enable advanced profiling (Uncheck this option).

-1

add these line to your gradle:

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}