【问题标题】:Cloud Firestore : DexArchiveMergerException Unable to merge dexCloud Firestore:DexArchiveMergerException 无法合并 dex
【发布时间】:2018-04-28 06:44:41
【问题描述】:

当我包括:

编译'com.firebaseui:firebase-ui-firestore:3.1.0'

构建失败。 firestore 3.0.0 版结果相同。

没有此代码,构建成功。

是否有重复的模块?请帮帮我。

错误:任务执行失败 ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.

java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: 无法合并 索引

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.android"
        minSdkVersion 16
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

        // firebase
        resConfigs "auto"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    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'

    // volley
    compile 'com.android.volley:volley:1.0.0'

    // firebase, map, location
    implementation 'com.google.android.gms:play-services-maps:11.4.2'
    implementation 'com.google.android.gms:play-services-location:11.4.2'

    // firebase storage
    compile 'com.google.firebase:firebase-storage:11.4.2'

    // FirebaseUI for Firebase Auth
    compile 'com.firebaseui:firebase-ui-auth:3.1.0'

    // Required only if Facebook login support is required
    compile 'com.facebook.android:facebook-login:4.27.0'

    // Required only if Twitter login support is required
    compile("com.twitter.sdk.android:twitter-core:3.0.0@aar") { transitive = true }

    // glide
    compile 'com.github.bumptech.glide:glide:4.3.1'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.3.1'

    // FirebaseUI Storage
    compile 'com.firebaseui:firebase-ui-storage:3.1.0'

    // Firebase cloud message
    compile 'com.google.firebase:firebase-messaging:11.4.2'

    // FirebaseUI for Cloud Firestore
    compile 'com.firebaseui:firebase-ui-firestore:3.1.0'
}

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

buildscript {

    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'
        //firebase
        classpath 'com.google.gms:google-services:3.1.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()


        // glide
        mavenCentral()
        maven { url 'https://maven.google.com' }

        // firebase twitter login
        maven { url 'https://maven.fabric.io/public' }

    }
}

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

【问题讨论】:

    标签: java android google-cloud-firestore


    【解决方案1】:

    您的代码没有任何问题。几天前我遇到了同样的问题,我很简单地解决了这个问题:

    1. Clean
    2. Rebuild
    

    不要忘记在您的build.gradle 文件中也包含以下代码行(模块:app)。

    android {
        defaultConfig {
           multiDexEnabled true
        }
    }
    

    如果它仍然无法按上述说明工作,只需delete the .gradle directory 然后run your app again

    【讨论】:

    • 非常感谢!添加 multiDexEnabled true 后问题已修复。我很好奇,因为这个错误在我构建 android 时发生了很多次。添加代码是什么意思?你能解释一下吗?
    • 我遇到了同样的问题,在这里找到了答案。 developer.android.com/studio/build/multidex
    猜你喜欢
    • 2018-02-26
    • 2018-05-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-05
    • 1970-01-01
    相关资源
    最近更新 更多