【问题标题】:Android Error while merging dex archives合并dex档案时出现Android错误
【发布时间】:2018-04-01 06:12:31
【问题描述】:

更新我的 android studio 和 build tool 版本后出现此错误。我已尝试通过互联网解决此问题的所有可用解决方案,但未成功 不知道为什么会这样??

Android 工作室版本:3.1

Gradle 版本“:4.4

Gradle 插件:3.1

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.

我的 build.gradle 文件

apply plugin: 'com.android.application'
android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.abc.abc"
        minSdkVersion 21
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        multiDexEnabled true //Tryed this but not worked
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    repositories {
        maven {
            url 'https://github.com/jitsi/jitsi-maven-repository/raw/master/releases'
        }
//    maven { url "https://dl.bintray.com/michelelacorte/maven/" }
        mavenCentral()
    }
    configurations {
        all*.exclude module: 'support-v4'
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:27.1.0'
    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.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:design:27.1.0'
    implementation 'com.android.support:cardview-v7:27.1.0'
    implementation 'com.android.support:support-fragment:27.1.0'
    // multipart entity
    implementation('org.apache.httpcomponents:httpmime:4.+') {
        exclude module: "httpclient"
    }
    implementation 'com.oguzdev:CircularFloatingActionMenu:1.0.2'
    //    implementation 'com.wonderkiln:camerakit:0.13.0'
    implementation 'com.getbase:floatingactionbutton:1.10.1'
    implementation 'org.jitsi.react:jitsi-meet-sdk:1.9.0'
    //    compile 'com.google.code.gson:gson:2.2.4'
    //    compile 'com.android.support:support-emoji:26.0.1'
    implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
    implementation 'com.android.volley:volley:1.1.0'
    implementation 'com.miguelcatalan:materialsearchview:1.4.0'
    implementation 'com.yalantis:ucrop:2.2.0-native'
    implementation 'com.pnikosis:materialish-progress:1.7'
    implementation 'org.igniterealtime.smack:smack-android-extensions:4.2.0'
    implementation 'org.igniterealtime.smack:smack-experimental:4.2.0'
    implementation 'org.igniterealtime.smack:smack-tcp:4.2.0'
    implementation 'org.apache.commons:commons-lang3:3.4'
    implementation 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
    implementation 'com.googlecode.libphonenumber:libphonenumber:7.0.4'
    implementation 'org.greenrobot:eventbus:3.1.1'
    implementation 'com.google.android.gms:play-services-places:11.8.0'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'com.google.android.gms:play-services-maps:11.8.0'
    implementation 'com.github.bumptech.glide:glide:4.6.1'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
    implementation 'com.eyalbira.loadingdots:loading-dots:1.0.2'
    implementation 'de.hdodenhof:circleimageview:2.1.0'
    // implementation 'com.google.android.exoplayer:exoplayer:2.7.1'
    //    compile 'it.michelelacorte.swipeablecard:library:2.3.0@aar'{
    //        exclude module: 'appcompat-v7'
    //        exclude group: 'com.android.support'
    //    }
    // BUTTER KNIFE
    implementation('com.jakewharton:butterknife:8.5.1') {
        exclude module: 'appcompat-v7'
        exclude group: 'com.android.support'
    }
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
    //    implementation project(':libemoji')
    implementation 'com.android.support:support-v13:27.1.0'
}

这几乎浪费了我的 10 天... 遇到过的最令人困惑的错误..

【问题讨论】:

  • 您是否清理并重建了您的应用程序?
  • @vikassingh 100 次
  • 低于 versionName 只需添加这个multiDexEnabled true 并尝试清理项目并运行
  • @AmjadKhan 同样的错误
  • multidex 在这里不是问题。当您达到超过 64k 的方法时,您会在不使用 multiDexEnabled true 时得到不同的错误签名。此错误似乎与 gradle 依赖项之一中相同库和不同版本的使用冲突。

标签: android android-studio android-gradle-plugin build.gradle


【解决方案1】:

如果您的代码有两个不同的模块 google-play-servicessupport-v4,它们使用这些库的不同版本。 检查您在项目中使用的库的依赖关系或使用

gradle app:dependencies

查看项目的依赖关系树,然后当您发现哪些库用于不同版本时,将其添加到具有正确版本的依赖项中。例如,如果 google-play-services:location:11.2.0 出现在您的依赖项中,请将其替换为 google-play-services:location:11.8.0

在这种情况下,您通常会在 build.gradle 文件中看到警告或错误消息(即,一个依赖项将标有红色下划线,表明它会导致版本不匹配)。

【讨论】:

  • 在 web 控制台中检查依赖问题更好:./gradlew app:dependencies --scan
【解决方案2】:

在我的例子中,项目和模块的包名是相同的。在调试模式下运行时,一切正常。但是当我想建立发布模式时。我得到了这个错误。重命名包名是我的解决方案。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-04-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-31
    • 2020-12-03
    相关资源
    最近更新 更多