3

我开始收到以下错误

错误:任务“:app:transformDexArchiveWithExternalLibsDexMergerForDebug”的执行失败。java.lang.RuntimeException:java.lang.RuntimeException:com.android.builder.dexing.DexArchiveMergerException:无法合并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
}

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

4

2 回答 2

1

在stackoverflow上尝试了所有解决方案后我已经解决了,尝试按顺序执行以下步骤

  1. 用实现替换所有编译
  2. 使所有 supportLibraryVersion = '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. 文件->使缓存无效/重新启动
  5. 构建 > 清理项目
  6. 添加

依赖项{实现'com.android.support:multidex:1.0.1'}

  1. 添加

android { defaultConfig { multiDexEnabled true } }

  1. 异步项目

最后这是我的 App 文件

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'
}

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

所以如果有人知道,请告诉我完整的细节

我希望这能帮到您

于 2018-02-28T23:06:38.120 回答
-1

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

就这样做

实现>>>注释处理器

于 2018-06-09T07:21:17.880 回答