5
votes

After migrating to AndroidX, I have the following issue as a result of the migration:

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.

    com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: /home/lexy/AndroidStudioProjects/Testbucks/app/build/intermediates/transforms/dexBuilder/debug/0.jar, /home/lexy/AndroidStudioProjects/Testbucks/app/build/intermediates/transforms/dexBuilder/debug/1.jar, /home/lexy/AndroidStudioProjects/Testbucks/app/build/intermediates/transforms/dexBuilder/debug/2.jar, /home/lexy/AndroidStudioProjects/Testbucks/app/build/intermediates/transforms/dexBuilder/debug/3.jar, /home/lexy/AndroidStudioProjects/Testbucks/app/build/intermediates/transforms/dexBuilder/debug/4.jar, /home/lexy/AndroidStudioProjects/Testbucks/app/build/intermediates/transforms/dexBuilder/debug/5.jar, /home/lexy/AndroidStudioProjects/Testbucks/app/build/intermediates/transforms/dexBuilder/debug/6.jar, /home/lexy/AndroidStudioProjects/Testbucks/app/build/intermediates/transforms/dexBuilder/debug/7.jar, /home/lexy/AndroidStudioProjects/Testbucks/app/build/intermediates/transforms/dexBuilder/debug/8.jar, /home/lexy/AndroidStudioProjects/Testbucks/app/build/intermediates/transforms/dexBuilder/debug/9.jar, /home/lexy/AndroidStudioProjects/Testbucks/app/build/intermediates/transforms/dexBuilder/debug/10.jar, /home/lexy/AndroidStudioProjects/Testbucks/app/build/intermediates/transforms/dexBuilder/debug/11.jar, /home/lexy/AndroidStudioProjects/Testbucks/app/build/intermediates/transforms/dexBuilder/debug/12.jar, /home/lexy/AndroidStudioProjects/Testbucks/app/build/intermediates/transforms/dexBuilder/debug/13.jar, /home/lexy/AndroidStudioProjects/Testbucks/app/build/intermediates/transforms/dexBuilder/debug/14.jar, /home/lexy/AndroidStudioProjects/Testbucks/app/build/intermediates/transforms/dexBuilder/debug/15.jar... Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes. Program type already present: androidx.concurrent.futures.DirectExecutor

Has anyone come across a similar issue, as I have not found any solutions to this problem in any forum.

1
I also upgraded to AndroidX and got this issue. :( Still stuck with the below errors. - Caused by: com.android.tools.r8.utils.AbortException: Error: Program type already present: androidx.concurrent.futures.DirectExecutor Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complet - Sumit Saurabh
I don't think that issue has a solution yet, because i have searched everywhere, can't find any solution, the issue is not common... - Olakunle Irantiola
I am also empty-handed. Looks like I will have to revert back to older libraries. :( - Sumit Saurabh
I am currently fed up, I don't know what to do, I can't move on - Olakunle Irantiola
Hadn't you taken any backup? and if you refactored the code through "Migrate to Androidx", Android studio would have asked for the zipped backup. I moved back to the older codebase. - Sumit Saurabh

1 Answers

10
votes

After migrating to AndroidX, I had a similar issue and the issue was because of Guava. The way I resolved it was to include the following:

configurations {
    all*.exclude group: 'com.google.guava', module: 'listenablefuture'
}

In the (Module:app), most solutions suggest that if you encounter this issue you include the following, in your module gradle:

implementation("android.arch.work:work-runtime:1.0.0-alpha09") {
    exclude group: 'com.google.guava', module: 'listenablefuture' 
}

This results in the following issue: Program type already present androidx.concurrent.futures.DirectExecutor.