Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix "Program type already present: androidx.concurrent.futures.DirectExecutor"

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.

like image 773
Olakunle Irantiola Avatar asked Jan 01 '19 20:01

Olakunle Irantiola


1 Answers

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.

like image 163
George Avatar answered Nov 08 '22 19:11

George