Friday, 24 March 2017

android - 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.


Answer



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.


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...