1

Error:Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.

java.io.IOException: Can't write [C:\Users\ACERNRC\Desktop\WORK\woo\woo_1\FashionsNrc\app\build\intermediates\multi-dex\debug\componentClasses.jar] (Can't read [C:\Users\ACERNRC.gradle\caches\transforms-1\files-1.1\Woocommerce-Android-Client-0.0.3.aar\c97bb2466b99eaef9958dcb4fe44dc0d\jars\libs\google-http-client-1.20.0.jar(;;;;;;**.class)] (Duplicate zip entry [google-http-client-1.20.0.jar:com/google/api/client/json/JsonPolymorphicTypeMap$TypeDef.class]))

How to solve this?

This is my app gradle file, after multidex option hide in default config

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.acernrc.fashionsnrc"
        minSdkVersion 16
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
       // multiDexEnabled true
      /**  dexOptions {

            jumboMode true
            javaMaxHeapSize "4g"

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

repositories {
    jcenter()

    maven {
        url "https://jitpack.io"
    }
}
dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    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'
    implementation  'com.github.rajatady:Woocommerce-Android-Client:0.0.3'
    implementation  'com.github.vajro:MaterialDesignLibrary:1.6'
    implementation  'com.github.ozodrukh:CircularReveal:1.3.1@aar'
    debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
    implementation project(':woocommerce')
}

After sync shows Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.

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

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
simi k b
  • 11
  • 1
  • 3
  • Possible duplicate of [Android- Error:Execution failed for task ':app:transformClassesWithDexForRelease'](https://stackoverflow.com/questions/35890257/android-errorexecution-failed-for-task-apptransformclasseswithdexforrelease) – Fenil Patel Dec 29 '17 at 09:35
  • 1
    @FenilPatel, how about [Android MultiDex: an all time salvation is imperative](https://stackoverflow.com/questions/46104198/android-multidex-an-all-time-salvation-is-imperative) which is actually about the same com.android.builder.dexing.DexArchiveMergerException? – NH. Dec 29 '17 at 17:11
  • Do you really need `implementation project(':woocommerce')` if you already are compiling `implementation 'com.github.rajatady:Woocommerce-Android-Client:0.0.3'`? I tried to run `transformDexArchiveWithExternalLibsDexMergerForDebug` for your configuration without that dependency since of course I don't have it and everything was fine. Try removing that line if it is not necessary. – Roberto Martucci Dec 29 '17 at 21:32
  • @simi how you solved this problem any guide will be helpful i tried all the ans but non working for me. – Neelay Srivastava Apr 25 '18 at 21:06

3 Answers3

0

In your local.properties file just add size mentioned below

org.gradle.jvmargs=-XX:MaxHeapSize\=512m -Xmx512m

In your app gradle

defaultConfig {
    applicationId "<PACKAGE NAME>"
    minSdkVersion 8
    versionCode 1
    versionName "1.0"
    targetSdkVersion 26

    multiDexEnabled true //this is important
}
Nikhil Lotke
  • 605
  • 7
  • 15
  • There is a comment in the file as `This file is automatically generated by Android Studio. Do not modify this file -- YOUR CHANGES WILL BE ERASED!` – Daksh Agrawal Mar 16 '18 at 15:48
0

Try this

In build.gradle:

defaultConfig {
   multiDexEnabled true
}

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

Clean your project and rebuild.

kamal verma
  • 496
  • 3
  • 16
0

In build.gradle:

defaultConfig {
   multiDexEnabled true
}


dependencies {
implementation  'com.android.support:multidex:1.0.3'
}

But notice that you use the old version sdk

younes
  • 742
  • 7
  • 8