0

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

java.io.IOException: Can't write [/home/android1/Android/projects/ezeparents/app/build/intermediates/multi-dex/debug/componentClasses.jar] (Can't read [/home/android1/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpcore/4.3.2/31fbbff1ddbf98f3aa7377c94d33b0447c646b6e/httpcore-4.3.2.jar(;;;;;;**.class)] (Duplicate zip entry [httpcore-4.3.2.jar:org/apache/http/annotation/NotThreadSafe.class]))

build.gradle

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}


android {
    compileSdkVersion 26
    buildToolsVersion '26.0.2'
    defaultConfig {
        applicationId "com.ezeparents"
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
        multiDexEnabled = true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    android {

        packagingOptions {
            exclude 'META-INF/DEPENDENCIES'
            exclude 'META-INF/NOTICE'
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/LICENSE.txt'
            exclude 'META-INF/NOTICE.txt'
            exclude 'META-INF/ECLIPSE_.SF'
            exclude 'META-INF/ECLIPSE_.RSA'
            exclude  'org/apache/http/annotation/NotThreadSafe.class'

        }


    }


}
configurations {
    all*.exclude group: 'xpp3', module: 'xpp3'
}

dependencies {
    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.crashlytics.sdk.android:crashlytics:2.6.7@aar') {
        transitive = true;
    }

    compile 'com.github.nguyenhoanglam:ImagePicker:1.2.1'
    compile 'com.roomorama:caldroid:3.0.1'
    compile 'com.android.support:appcompat-v7:26.0.1'
    compile 'com.android.support:design:26.0.1'
    compile 'com.github.scottyab:showhidepasswordedittext:0.8'
    compile 'com.android.support:recyclerview-v7:26.0.1'
    compile 'com.android.support:cardview-v7:26.0.1'
    compile 'me.relex:circleindicator:1.2.2@aar'
    compile 'com.hedgehog.ratingbar:app:1.1.2'
    compile 'com.squareup.okhttp3:okhttp:3.8.1'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.facebook.android:facebook-android-sdk:4.+'
    compile 'de.hdodenhof:circleimageview:2.1.0'
    compile 'com.github.fiskurgit:ChipCloud:2.1.0'
    compile 'com.squareup.retrofit2:converter-gson:2.3.0'
    compile 'com.theartofdev.edmodo:android-image-cropper:2.3.+'
    compile 'com.kyleduo.switchbutton:library:1.4.4'
    compile 'com.getkeepsafe.taptargetview:taptargetview:1.9.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.1'
    compile 'com.google.firebase:firebase-messaging:11.4.2'
    compile 'com.google.android.gms:play-services-auth:11.4.2'
    compile 'com.google.android.gms:play-services-location:11.4.2'
    compile 'com.google.android.gms:play-services-places:11.4.2'
    compile 'org.igniterealtime.smack:smack-android:4.1.0-rc1'
    compile 'org.igniterealtime.smack:smack-tcp:4.1.0-rc1'
    compile 'org.igniterealtime.smack:smack-android-extensions:4.1.0-rc1'
    compile 'com.android.volley:volley:1.0.0'
    compile 'com.googlecode.android-query:android-query:0.24.3'
    compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
    compile 'com.google.firebase:firebase-auth:11.4.2'
    compile 'uk.co.chrisjenx:calligraphy:2.3.0'
    testCompile 'junit:junit:4.12'
    compile 'com.github.nguyenhoanglam:ImagePicker:1.2.1'
    compile 'com.github.hani-momanii:SuperNova-Emoji:1.1'
    compile 'org.apache.commons:commons-lang3:3.5'
    compile 'com.android.support:multidex:1.0.2'
}

apply plugin: 'com.google.gms.google-services'
  • need more information. Please attach gradle build file. – Mykhailo Voloshyn Oct 26 '17 at 09:17
  • I suppose you have problems with apache httpcomponens. Try to clear project and after that rerun gradle sync. Also try to check this issue(Duplicate zip entry [httpcore-4.3.2.jar:org/apache/http/annotation/NotThreadSafe.class]))) – Mykhailo Voloshyn Oct 26 '17 at 09:19
  • @MykhailoVoloshyn Today i upgraded my android studio to 3.0 and thereafter I am facing this problem. I already enabled multiDexEnabled = true and also clean my project. still facing same issue while running application not while sync. – vikas singh Oct 26 '17 at 09:22
  • Please attach libraries name inside you lib folder – AbuQauod Oct 26 '17 at 09:23
  • @AbuQauod i dont have any jar dependency – vikas singh Oct 26 '17 at 09:28
  • @vikassingh i have the same error. i appreciate if you can help to figure out. I have tried different things suggested here. it didn't worked. – Hardik1344 Apr 16 '18 at 07:25

2 Answers2

1

Please clear you dependencies. You have an error, because you have a lot of libraries, that have same functionality. Also

Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.3.2 is ignored for release as it may be conflicting with the internal version provided by Android.

In my opinion the problem is in

compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'org.apache.commons:commons-lang3:3.5'

This two libraries can have same classes, so you need to exclude one of them, or exclude this duplicates. You can try

android {

...


    packagingOptions {
           exclude  'org/apache/http/annotation/NotThreadSafe.class'
    }
}

Pretty the same topic(Gradle build error : Duplicate entry)

  • Thank you for suggestion, but it didn't work for me. I upgrade my gradle according to your suggestion. Please check it – vikas singh Oct 26 '17 at 11:08
  • Work: compile ('org.apache.httpcomponents:httpcore:4.4.4') { exclude group: 'org.apache.http.annotation.NotThreadSafe' } Didn't work: compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2' – vikas singh Oct 26 '17 at 11:18
0

the above answer may also be correct, but it seems also an issue of the new google repo

add google as in below

In your root level gradle.build use below

buildscript {
    repositories {
        mavenCentral()
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenCentral()
        jcenter()
        google()
    }
}

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

and in your gradle-wrapper.properties file change the wrapper version as below

distributionUrl=https\://services.gradle.org/distributions/gradle-4.2.1-all.zip
Niraj Sanghani
  • 1,493
  • 15
  • 23