0

I'm trying to run my project, but for some reason it gives me that error

Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'. com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

I saw few solutions, but none of them helps me. What I'm missing here?

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'
Dimitar
  • 4,402
  • 4
  • 31
  • 47
E.Bolandian
  • 553
  • 10
  • 35
  • See [Configure your app for multidex](https://developer.android.com/studio/build/multidex.html#mdex-gradle). Also don't forget the multidex support dependencies and setup. – laenger Nov 21 '17 at 18:27
  • This has been a common error for me on Android Studio 3.0. You do not need to enable multidex unless you hit the 65k method limit which I doubt you are currently. WHat I do to solve this when it comes up is to a clean, enable multidex with `multiDexEnabled true`, build, remove multidex and build again – tyczj Nov 21 '17 at 18:50
  • I suggest that you edit your question and post the entire Gradle Console output, not just this error message. The details of the cause of the error should be elsewhere in the Gradle Console output. – CommonsWare Nov 21 '17 at 18:52
  • Its just give me that error. only these 2 lines – E.Bolandian Nov 21 '17 at 19:09
  • Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'. > java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex – E.Bolandian Nov 21 '17 at 19:13
  • Could be this? https://issuetracker.google.com/issues/68144982 – Marc Nov 21 '17 at 19:45

2 Answers2

0

add in Gradle

  defaultConfig {
    multiDexEnabled true
}

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

in Android Manifest

<application
    android:name="android.support.multidex.MultiDexApplication"
 ...........
Ramy Réz
  • 60
  • 6
0

FirebaseUI has a strict dependency towards a fixed Firebase/Play Services Version that you have to comply to. Ergo, your versions are not in sync.

You use:

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

and then

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'

However, FirebaseUI 3.1.0 requires Firebase/Play Services 11.4.2.

The next version of FirebaseUI is 3.1.2, which needs Firebase/Play Services 11.6.2.

For the full and future reference - the FirebaseUI-Android dependencies list.

Dimitar
  • 4,402
  • 4
  • 31
  • 47