Android Studio 3.0 任务执行失败:无法合并 dex

新手上路,请多包涵

android studio 在构建执行时遇到构建错误,如下所示:

错误:任务“:app:transformDexArchiveWithExternalLibsDexMergerForDebug”的执行失败。 java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: 无法合并 dex”

我的应用程序:build.gradle 文件:

 apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.2'
    defaultConfig {
        applicationId "com.pdroid.foodieschoice"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.firebaseui:firebase-ui-auth:2.3.0'

    testCompile 'junit:junit:4.12'
}
configurations.all {
    resolutionStrategy {
        force 'com.android.support:appcompat-v7:26.0.1'
        force 'com.android.support:support-compat:26.0.1'
        force 'com.android.support:support-core-ui:26.0.1'
        force 'com.android.support:support-annotations:26.0.1'
        force 'com.android.support:recyclerview-v7:26.0.1'
    }
}

apply plugin: 'com.google.gms.google-services'

任何解决方案

编辑:我已经通过firebase github站点完成了示例并解决了

原文由 Anguraj 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 546
1 个回答

我也得到了类似的错误。

问题

在此处输入图像描述

解决方案

此问题的主要原因是未启用 multiDex。所以在 Project/android/app/build.gradle 中, 启用 multiDex

有关详细信息,请参阅文档: https ://developer.android.com/studio/build/multidex#mdex-gradle

在此处输入图像描述

原文由 Shriram Navaratnalingam 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题