【问题标题】:Unable to merge dex in Android Studio when building app构建应用程序时无法在Android Studio中合并dex
【发布时间】:2018-03-14 22:30:02
【问题描述】:

我在 Android Studio 中收到此错误:

Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

使用此应用程序的 gradle 文件:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.3"
    defaultConfig {
        applicationId "com.example.android.kotlintest"
        minSdkVersion 23
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation "com.android.support:appcompat-v7:$supportVersion"
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation "com.android.support:design:$supportVersion"
    implementation "com.android.support:support-v13:$supportVersion"

    testCompile 'junit:junit:4.12'
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

    implementation 'com.squareup.retrofit2:retrofit:2.3.0'
    implementation 'com.github.bumptech.glide:glide:3.8.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
}
repositories {
    mavenCentral()
}

另外,$supportVersion 是 = '26.+'

我无法弄清楚是什么配置导致了这种情况。我尝试过清理和重建,并添加了multiDexEnabled true,但没有任何效果。

任何帮助将不胜感激!

【问题讨论】:

标签: android kotlin kotlin-android-extensions


【解决方案1】:

对我来说,这是由于使用了混合版本的依赖项。尝试将它们更改为相同的版本..

【讨论】:

    【解决方案2】:

    您是否尝试过清理构建并再次构建?

    【讨论】:

    • 这必须是评论,请避免发布答案,这只是建议。
    猜你喜欢
    • 1970-01-01
    • 2018-06-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多