Dexarchivebuilderexception with Guava 21.0

Asked

Viewed 20 times

0

I just received an Exception when I went to update the versions of the frameworks and run an application that was long stalled. My dependencies are these:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:27.1.0'
    annotationProcessor 'com.jakewharton:butterknife:7.0.1'
    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'com.google.code.gson:gson:2.8.2'
    compile 'com.google.guava:guava:23.3-android'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.squareup.okhttp:okhttp:'
    compile 'com.squareup.okhttp:okhttp-urlconnection:2.7.5'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.google.code.gson:gson:2.8.2'
    compile 'com.squareup.dagger:dagger:1.2.5'
    compile 'com.android.support:design:27.1.0'
    compile 'com.google.zxing:core:3.2.0'
    compile 'com.google.zxing:android-core:3.2.0'
    compile 'com.google.zxing:android-integration:3.2.0'
    compile 'commons-codec:commons-codec:1.5'
    annotationProcessor 'com.squareup.dagger:dagger-compiler:1.2.5'
    provided 'com.squareup.dagger:dagger-compiler:1.2.5'
    androidTestCompile 'org.mockito:mockito-core:'
    androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2'
    androidTestCompile 'com.android.support:support-annotations:27.1.0'
    androidTestCompile 'com.android.support.test:runner:1.0.1'
    androidTestCompile 'com.android.support.test:rules:1.0.1'
    androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.1'
    androidTestCompile ('com.android.support.test.espresso:espresso-contrib:2.2'){
        exclude module: 'support-annotations'
        exclude module: 'support-v4'
        exclude module: 'support-v13'
        exclude module: 'recyclerview-v7'
    }
    androidTestCompile 'com.android.support.test.espresso:espresso-intents:3.0.1'
}

And the Exception I got was this:

    Error:com.android.builder.dexing.DexArchiveBuilderException: Failed to process /home/tassio/.gradle/caches/modules-2/files-2.1/com.google.guava/guava/21.0/3a3d111be1be1b745edfa7d91678a12d7ed38709/guava-21.0.jar
    Error:com.android.builder.dexing.DexArchiveBuilderException: Error while dexing com/google/common/collect/ImmutableSortedAsList.class
    Error:com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
    Error:Execution failed for task ':app:transformClassesWithDexBuilderForQuiosqueDebug'.
    > com.android.build.api.transform.TransformException: com.android.builder.dexing.DexArchiveBuilderException: com.android.builder.dexing.DexArchiveBuilderException: Failed to process /home/tassio/.gradle/caches/modules-2/files-2.1/com.google.guava/guava/21.0/3a3d111be1be1b745edfa7d91678a12d7ed38709/guava-21.0.jar

Because Guava in version 21 on Android launches the exception while being compiled to the Dalvik format (DEX)?

1 answer

0


Version 21 of Guava can only be used in Java 8 environment, and the application is probably in version 7.

The solution is to update the library to a unique version compatible with android. Below:

dependencies {
  compile 'com.google.guava:guava:23.3-android'
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.