【问题标题】:Unable to merge dex? [duplicate]无法合并dex? [复制]
【发布时间】:2018-05-05 07:54:06
【问题描述】:

我正在尝试运行我的项目,但由于某种原因它给了我这个错误

错误:任务 ':app:transformDexArchiveWithExternalLibsDexMergerForDebug' 执行失败。 com.android.builder.dexing.DexArchiveMergerException: 无法合并 dex

我看到的解决方案很少,但没有一个对我有帮助。我在这里缺少什么?

Gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.2'

    defaultConfig {
        multiDexEnabled true
        applicationId "com.world.bolandian.talent"
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    //noinspection GradleCompatible
    implementation 'com.google.firebase:firebase-auth:11.6.0'
    implementation 'com.google.firebase:firebase-messaging:11.6.0'
    implementation 'com.google.firebase:firebase-storage:11.6.0'
    implementation 'com.google.firebase:firebase-database:11.6.0'
    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:appcompat-v7:26.+'
    compile 'com.android.support:design:26.+'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.beardedhen:androidbootstrap:2.3.2'
    compile 'com.github.mukeshsolanki:country-picker-android:1.1.9'
    compile 'com.android.support:cardview-v7:26.+'
    compile 'com.android.support:support-v4:26.+'
    compile 'com.mikhaellopez:circularimageview:3.0.2'
    compile 'com.github.clans:fab:1.6.4'
    compile 'com.firebaseui:firebase-ui-auth:3.1.0'
    testCompile 'junit:junit:4.12'
}

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

【问题讨论】:

  • Configure your app for multidex。也不要忘记 multidex 支持依赖和设置。
  • 这对我来说是 Android Studio 3.0 上的常见错误。除非您达到我怀疑您目前的 65k 方法限制,否则您不需要启用 multidex。当它出现时我要解决这个问题是清理,使用multiDexEnabled true启用multidex,构建,删除multidex并再次构建
  • 我建议您编辑您的问题并发布整个 Gradle 控制台输出,而不仅仅是此错误消息。错误原因的详细信息应在 Gradle 控制台输出中的其他位置。
  • 它只是给我那个错误。只有这两行
  • 错误:任务 ':app:transformDexArchiveWithExternalLibsDexMergerForDebug' 执行失败。 > java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: 无法合并 dex

标签: android gradle android-gradle-plugin


【解决方案1】:

在 Gradle 中添加

  defaultConfig {
    multiDexEnabled true
}

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

在 Android 清单中

<application
    android:name="android.support.multidex.MultiDexApplication"
 ...........

【讨论】:

  • 试过了,还是报错
【解决方案2】:

FirebaseUI 严格依赖您必须遵守的固定 Firebase/Play 服务版本。因此,您的版本不同步。

你使用:

compile 'com.firebaseui:firebase-ui-auth:3.1.0'

然后

implementation 'com.google.firebase:firebase-auth:11.6.0'
implementation 'com.google.firebase:firebase-messaging:11.6.0'
implementation 'com.google.firebase:firebase-storage:11.6.0'
implementation 'com.google.firebase:firebase-database:11.6.0'

但是,FirebaseUI 3.1.0 需要 Firebase/Play 服务 11.4.2

FirebaseUI 的下一个版本是 3.1.2,需要 Firebase/Play Services 11.6.2

完整的和未来的参考 - FirebaseUI-Android dependencies list

【讨论】:

    猜你喜欢
    • 2018-08-09
    • 2018-06-06
    • 2018-11-10
    • 1970-01-01
    • 2018-02-26
    • 1970-01-01
    • 2018-05-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多