android - 如何修复 "Program type already present: androidx.concurrent.futures.DirectExecutor"

标签 android android-studio gradle android-gradle-plugin androidx

迁移到 AndroidX 后,由于迁移,我遇到了以下问题:

失败:构建失败,出现异常。

  • 出了什么问题: 任务“: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

有没有人遇到过类似的问题,因为我在任何论坛上都没有找到解决这个问题的方法。

最佳答案

迁移到 AndroidX 后,我遇到了类似的问题,问题是因为 Guava。 我解决它的方法是包括以下内容:

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

在 (Module:app) 中,大多数解决方案建议如果遇到此问题,请在模块 gradle 中包含以下内容:

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

这会导致以下问题:程序类型已存在 androidx.concurrent.futures.DirectExecutor。

关于android - 如何修复 "Program type already present: androidx.concurrent.futures.DirectExecutor",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53998802/

相关文章:

java - 获取 DatePickerDialog 的取消按钮引用

android - 如何修复 "Content is not allowed in prolog"构建错误?

android-studio - Android 4.4 或更低版本上的 java.lang.NoClassDefFoundError

android - 如何使用 gradle 动态切换/更改 testInstrumentationRunner

java - 第一次和第二次 ACTION_DOWN 之间耗时

android - 我如何使用 "content://sms/inbox"获取 SMS 发件人联系人(人)保存的名称

java - 在TextView的不同行中为String设置不同的长度

gradle - 当出现任何标准错误时,Gradle 构建失败

firebase - 为什么 Firebase 安装过程会出现错误? flutter

安卓 NDK r10e "cannot find -lsupc++"