0

Please tell me what is the reason of this Exception

*Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.

java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex*

    implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:support-vector-drawable:26.1.0'
implementation 'com.google.firebase:firebase-database:11.0.4'
implementation 'com.google.firebase:firebase-storage:11.0.4'
implementation 'com.google.firebase:firebase-auth:11.0.4'
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'
compile 'io.paperdb:paperdb:2.6'
compile 'com.github.rey5137:material:1.2.4'
compile 'com.theartofdev.edmodo:android-image-cropper:2.6.+'
compile 'de.hdodenhof:circleimageview:2.2.0'
ADM
  • 20,406
  • 11
  • 52
  • 83
mohd irfan
  • 57
  • 9
  • 1
    Possible duplicate of [Unable to merge dex](https://stackoverflow.com/questions/46267621/unable-to-merge-dex) – ADM Mar 14 '18 at 11:48
  • Read [This discussion](https://stackoverflow.com/questions/48027019/how-to-manage-different-support-library-versions-for-3rd-party-deps-with-gradle). The problem is libraries and your project are using different versions of support libraries . – ADM Mar 14 '18 at 12:46

1 Answers1

0

add this to defaultConfig

multiDexEnabled true

and in dependencies

compile 'com.android.support:multidex:1.0.1'

In Android tag

   defaultConfig {
        applicationId "com.test.app"
        minSdkVersion 19
        targetSdkVersion 27
        versionCode 4
        versionName "1.3"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true

    }

    dexOptions {
        javaMaxHeapSize "4g"
    }
Syed
  • 166
  • 3
  • 15
  • still not working..after add these two things which add in comment then showing this error in below – mohd irfan Mar 14 '18 at 12:20
  • Error:Execution failed for task ':app:transformClassesWithMultidexlistForDebug'. > java.io.IOException: Can't write [E:\irfan data\LiveSelfie2\app\build\intermediates\multi-dex\debug\componentClasses.jar] (Can't read [C:\Users\work\.gradle\caches\transforms-1\files-1.1\support-core-ui-27.1.0.aar\6c349993f8e00cdcfe9926756c17c684\jars\classes.jar(;;;;;;**.class)] (Duplicate zip entry [classes.jar:android/support/design/widget/CoordinatorLayout$Behavior.class])) – mohd irfan Mar 14 '18 at 12:20
  • try to add this in android { ------- dexOptions { javaMaxHeapSize "4g" } ------} – Syed Mar 14 '18 at 12:26
  • mean i have to add this in which place???? dexOptions { javaMaxHeapSize "4g" } – mohd irfan Mar 14 '18 at 12:39
  • after closing defaultConfig brace paste that code check answer – Syed Mar 14 '18 at 12:45
  • android { compileSdkVersion 26 defaultConfig { multiDexEnabled true – mohd irfan Mar 14 '18 at 12:51
  • applicationId "com.logiclump.technologies.liveselfie" minSdkVersion 19 targetSdkVersion 26 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary = true } dexOptions { javaMaxHeapSize "4g" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } – mohd irfan Mar 14 '18 at 12:52
  • still same error after add your code see my all code – mohd irfan Mar 14 '18 at 12:52
  • In my case helped an update of libraries defined inside app gradle file to newest versions: `'compile 'com.android.support:appcompat-v7:27.1.0'` and `'compile 'com.android.support:design:27.1.0'` – grabarz121 Mar 14 '18 at 15:00