无法合并 Dex - Android Studio 3.0.1 DexArchiveMergerException

Unable to Merge Dex - Android Studio 3.0.1 DexArchiveMergerException

我开始收到以下错误

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

我尝试重置我的备份,但还是出现了同样的问题

我尝试了所有解决方案,例如

multiDexEnabled true

正在清理并重建项目,但没有用。任何帮助将不胜感激。

应用文件

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    buildToolsVersion '27.0.2'
    defaultConfig {
        applicationId "com.example"
        minSdkVersion 18
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
        resConfigs "auto"

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
ext {
    supportLibraryVersion = '27.0.2'
    grpcVersion = '1.4.0'
}
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
    testImplementation 'junit:junit:4.12'
//appcompat libraries
    compile 'com.android.support:design:27.0.2'
    compile 'com.android.support:appcompat-v7:27.0.2'
    implementation 'com.android.support:support-v4:27.1.0'

//butterknife
    compile 'com.jakewharton:butterknife:8.8.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'

//retrofit
    implementation 'com.squareup.retrofit2:retrofit:2.3.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
    implementation 'com.squareup.okhttp3:okhttp:3.8.0'
    implementation 'com.jakewharton.retrofit:retrofit1-okhttp3-client:1.0.2'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.scottyab:aes-crypto:0.0.4'
//circleimageview
    implementation 'de.hdodenhof:circleimageview:2.2.0'
//ZXing for barCode reader
    compile 'com.journeyapps:zxing-android-embedded:3.2.0@aar'
    compile 'com.google.zxing:core:3.2.1'
//gson
    compile 'com.google.code.gson:gson:2.8.2'
//recyclerview and cardview
    implementation 'com.android.support:cardview-v7:27.0.2'
    compile 'com.android.support:recyclerview-v7:+'
//play-services
    compile 'com.google.android.gms:play-services-maps:11.8.0'




    implementation 'com.github.bumptech.glide:glide:4.3.1'
    implementation 'com.jaeger.statusbarutil:library:1.4.0'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    compile 'com.android.support:support-annotations:27.0.2'
    compile 'com.wang.avi:library:2.1.3'

}

项目文件

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'

    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

我在这里查看了许多其他问题和答案,但似乎找不到可以解决问题的解决方案:(

我在Whosebug上尝试了所有的解决方案后都解决了,请尝试按顺序执行以下步骤

  1. 用实现替换所有编译
  2. 使所有支持LibraryVersion = '27.0.2'
  3. 改变

'com.google.android.gms:play-services-maps:11.8.0'

'com.google.android.gms:play-services-maps:11.4.0'

  1. 删除所有未使用的库
  2. 删除项目中的 .gradle 文件夹
  3. 删除构建文件夹和 gradle 缓存
  4. 文件 -> 无效 caches/restart
  5. 构建 > 清理项目
  6. 添加

dependencies { implementation 'com.android.support:multidex:1.0.1'}

  1. 添加

android { defaultConfig { multiDexEnabled true } }

  1. 异步项目

最后这是我的应用程序文件

apply plugin: 'com.android.application'

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

}
ext {
    supportLibraryVersion = '27.0.2'

}
dependencies {

    implementation fileTree(dir: 'libs', include: ['*.jar'])
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'

    implementation 'com.android.support:support-v4:27.0.2'
    implementation 'com.android.support:appcompat-v7:27.0.2'
    implementation 'com.android.support:design:27.0.2'


//constraint
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'

//butterknife
    implementation  'com.jakewharton:butterknife:8.8.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
//avi:library
    implementation  'com.wang.avi:library:2.1.3'

//circleimageview
    implementation 'de.hdodenhof:circleimageview:2.2.0'

//retrofit2
    implementation 'com.squareup.retrofit2:retrofit:2.3.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
    implementation 'com.squareup.okhttp3:okhttp:3.8.0'
    implementation 'com.jakewharton.retrofit:retrofit1-okhttp3-client:1.0.2'


//recyclerview and cardview
    implementation  'com.android.support:recyclerview-v7:27.0.2'
    implementation 'com.android.support:cardview-v7:27.0.2'


//ZXing for barCode reader
    implementation  'com.journeyapps:zxing-android-embedded:3.2.0@aar'
    implementation  'com.google.zxing:core:3.2.1'

//play-services
    implementation  'com.google.android.gms:play-services-maps:11.4.0'

//gson
    implementation  'com.google.code.gson:gson:2.8.2'
//statusbarutil
    implementation  'com.jaeger.statusbarutil:library:1.4.0'
//glide
    implementation 'com.github.bumptech.glide:glide:4.6.1'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
//multidex
    implementation 'com.android.support:multidex:1.0.1'
}

ِِ其实我不明白它的真正原因以及为什么突然发生这种情况

因此,如果有人知道,请告诉我详细信息

希望对您有所帮助

在浪费几个小时后,这对我有用

就这样做

Implementation >>> annotationProcessor