Search code examples
androidandroid-multidex

java.util.zip.ZipException: duplicate entry: org/apache/http/HttpMessage.class


I'm getting the following error. I have not tried to solve it the last two days, but nothing had solved the problem. Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.

java.util.zip.ZipException: duplicate entry: org/apache/http/HttpMessage.class here is my build.gradle(app)

apply plugin: 'com.android.application'


android {
compileSdkVersion 23
buildToolsVersion '23.0.0'

defaultConfig {
    applicationId "com.mycompany.newlogin"
    minSdkVersion 15
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
}

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

}
useLibrary 'org.apache.http.legacy'
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:multidex:1.0.0'
compile 'com.google.guava:guava-jdk5:17.0'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'org.apache.httpcomponents:httpclient:4.5'
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'

}

please help me with this .thank you in advance.


Solution

  • Have a look at your referenced packages, org.jbundle.util.osgi.wrapped.org.apache.http.client seems to contain at least some classes of httpcore, especially that one mentioned in your error message. So I guess you simply can't and shouldn't use both as dependencies, but only the ones you really need.