Search code examples
androidgradleandroid-gradle-pluginandroid-multidex

Error ':app:packageAllDebugClassesForMultiDex'. > java.util.zip.ZipException: duplicate entry:


I am developing android application for Home Automation using gradle in Android Studio. There is no problem when I build the project, but when I try to run the project, there is an error like this:

Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'. java.util.zip.ZipException: duplicate entry: org/apache/http/params/CoreConnectionPNames.class

Here is my build.gradle codes:

 apply plugin: 'com.android.application'
    android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.cpl"
        minSdkVersion 15
        targetSdkVersion 23

        multiDexEnabled true
    }

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

    dependencies {
    compile 'com.android.support:support-v4:23.0.1'
    compile 'com.google.code.gson:gson:2.3.1'
    compile 'com.google.android.gms:play-services:+'
    compile 'com.android.support:appcompat-v7:23.0.1'

    compile files('libs/android.jar')
    compile files('libs/bcprov-jdk15on-1.47.jar')
    //compile files('libs/google-play-services.jar')
    //compile files('libs/google-play-services1.jar')
    compile files('libs/httpclient-4.2.3.jar')
    compile files('libs/httpcore-4.3.jar')
    compile files('libs/nineoldandroids-library-2.4.0.jar')
    compile files('libs/Pubnub-Android-3.7.2.jar')
    compile files('libs/renderscript-v8.jar')
    compile files('libs/sun.misc.BASE64Decoder.jar')
    compile files('libs/universal-image-loader-1.9.2.jar')
    //compile files('libs/android-support-multidex.jar')

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

}

please help me to solve this problem. Thank you anyway


Solution

  • Please change your gradle dependencies as following :

    compile 'com.android.support:support-v4:23.0.1'
    compile 'com.google.code.gson:gson:2.3.1'
    compile 'com.google.android.gms:play-services:+'
    compile 'com.android.support:appcompat-v7:23.0.1'
    
    compile files('libs/renderscript-v8.jar')
    compile files('libs/sun.misc.BASE64Decoder.jar')
    
    compile 'org.apache.httpcomponents:httpclient:4.2.3'
    compile 'org.bouncycastle:bcprov-jdk15on:1.47'
    compile 'org.apache.httpcomponents:httpcore:4.3'
    compile 'com.nineoldandroids:library:2.4.0'
    compile 'com.pubnub:pubnub-android:3.7.2'
    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.2'
    compile 'com.android.support:multidex:1.0.1'
    

    Note :

    In Gradle when we do not use gradle dependency and if our libs folder dependencies contains duplicate class then

    java.util.zip.ZipException: duplicate entry
    

    This exception occurs.

    So Whenever you add dependencies then if possible then try maximum to use maven dependencies.

    Thank you.!!