【问题标题】:Unable To Merge Dex Error While Running App运行应用程序时无法合并 Dex 错误
【发布时间】:2017-12-25 19:10:29
【问题描述】:

我正在尝试运行我的 Android 应用程序。它以前工作正常。可能是在新更新的 gradle 中运行它之后,我收到了这个错误

Error:java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Error:java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Error:com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Error:com.android.dex.DexException: Multiple dex files define Lorg/intellij/lang/annotations/JdkConstants$CursorType;

尝试了清洁和重建项目。每次重建时,每次运行时都会出现以下错误..

错误:任务 ':app:transformClassesWithMultidexlistForDebug' 执行失败。

java.io.IOException: 无法写入 [/PROJECT_LOCATION/app/build/intermediates/multi-dex/debug/componentClasses.jar] (无法读取 [/Applications/Android Studio.app/Contents/gradle /m2repository/org/jetbrains/annotations/13.0/annotations-13.0.jar(;;;;;;**.class)](重复的 zip 条目 [annotations-13.0.jar:org/intellij/lang/annotations/Flow.类]))

我的构建 Gradle 配置

compileSdkVersion 26
defaultConfig {
    applicationId "MY_ID"
    minSdkVersion 18
    targetSdkVersion 26
    versionCode 65
    versionName "5.5.38"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    multiDexEnabled true
    renderscriptTargetApi 14
    renderscriptSupportModeEnabled true

    vectorDrawables.useSupportLibrary = true
}

【问题讨论】:

    标签: java android android-studio intellij-idea gradle


    【解决方案1】:

    根据我的经验,当您的模拟器/移动设备中的 dex 版本无法与新建的版本无缝融合时,dexMerger 问题往往会发挥作用。

    1. 尝试在您的移动设备/模拟器上删除您的应用。然后重新安装。

    【讨论】:

    • 您是否尝试过确保您的应用程序模块中的build.gradle 依赖项是一致的,即您可能有某个供应商的两个依赖项,例如 1. implementation 'com.android.support:support-vector-drawable:27.0.2' implementation 'com.android.support:support-v4:27.0.1 这些依赖项可能相互依赖,但是,一个依赖项是 eg27.0.2 比 27.0.1 更新,这会导致库兼容性问题。尝试检查 build.gradle 中的 lib 版本警告
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-06-21
    • 2018-08-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-12
    • 1970-01-01
    相关资源
    最近更新 更多