Search code examples
androidandroid-gradle-pluginandroid-multidex

Authentication with FireBase using email id and password: Unable to Merge Dex


I found something new while doing research on firebase authentication functionality for my project. After enabling email and password type and using the given below library of firebase it shows me the error of unable to merge dex. Whenever I use this library I get this error.

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

Is this library is not compatible with the latest version of the android studio?

Here is my gradle:

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "htl.com.googlemaps"
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
        javaCompileOptions {
            annotationProcessorOptions {
                includeCompileClasspath true
            }
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.google.android.gms:play-services-maps:11.4.2'
    compile "com.google.android.gms:play-services-location:11.4.2"
    compile 'com.google.firebase:firebase-core:11.4.2'
    compile 'com.android.volley:volley:1.0.0'
    compile 'com.google.firebase:firebase-database:11.4.2'
    compile 'com.google.firebase:firebase-auth:11.4.2'
    compile 'com.google.android.gms:play-services-auth:11.4.2'
    compile 'com.firebaseui:firebase-ui-auth:3.1.0'
    compile 'com.firebase:firebase-client-android:2.5.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
}
apply plugin: 'com.google.gms.google-services'

I also attached the image of error on this issue.

enter image description here


Solution

  • You are getting

    com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

      FirebaseUI Version    Firebase/Play Services Version
        3.1.2                   11.6.2
        3.1.0                   11.4.2
        3.0.0                   11.4.2
        2.4.0                   11.4.0
    

    If you use 'com.firebaseui:firebase-ui-auth:3.1.0', Make sure your respective Firebase/Play version is 11.4.2.

    Example

    com.google.android.gms:play***:11.4.2
    com.google.firebase:firebase***:11.4.2