0

so I was trying to generate the APK file of an android project created in Android Studio and I keep getting the following error:

Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/http/concurrent/Cancellable.class

also here's my build.gradle file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"
    useLibrary 'org.apache.http.legacy'

    defaultConfig {
        applicationId "com.example.app"
        minSdkVersion 18
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile project(':vitamio')


    compile 'com.android.support:appcompat-v7:24.0.0-beta1'
    compile 'com.google.android.gms:play-services:9.0.1'
    compile 'com.google.android.gms:play-services-location:8.4.0'
    compile 'com.android.support:design:24.0.0-beta1'
    compile 'com.github.natasam:DemoProgressViewsLibApp:fa2f8f01e0'
    compile 'com.google.android.gms:play-services-ads:9.0.1'
    compile 'com.google.android.gms:play-services-auth:9.0.1'
    compile 'com.google.android.gms:play-services-gcm:9.0.1'
    compile 'org.apache.httpcomponents:httpcore:4.4.1'
    compile 'org.apache.httpcomponents:httpclient:4.5'
    compile group: 'cz.msebera.android' , name: 'httpclient', version: '4.4.1.1'
    compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1'
    compile 'com.android.support:multidex:1.0.0'
    compile 'com.google.android.gms:play-services-maps:8.3.0'
}

So can any one please tell me how I can solve that error ? I tried removing the http in dependencies but still error. Any respond is appricated. Thanks!

lino.lka
  • 1
  • 2
  • yeah that makes sense; I did that but still getting the same error – lino.lka Aug 17 '16 at 12:38
  • First thing If you are adding `compile 'com.google.android.gms:play-services:9.0.1'` you need not to add `compile 'com.google.android.gms:play-services-ads:9.0.1' compile 'com.google.android.gms:play-services-auth:9.0.1'` these dependencies google automatically imports all services from `compile 'com.google.android.gms:play-services:9.0.1`. By adding this multiple dependencies Android goes beyond max method limits. I knew that I was nowhere near the 65k method limit. Always specify only the services you need. For more details http://stackoverflow.com/a/35299382/2122328 – Sandeep Devhare Aug 17 '16 at 12:40
  • Thanks for that Sandeep, I did all of that and still approaching the same error – lino.lka Aug 17 '16 at 12:49
  • Did you check provided link in my comment. – Sandeep Devhare Aug 17 '16 at 12:51
  • yes, I did all of that and still same error – lino.lka Aug 17 '16 at 12:54
  • I Think You may not use `compile 'org.apache.httpcomponents:httpcore:4.4.1'` nor `compile fileTree(dir: 'libs', include: ['*.jar'])` at the same time. *.jar considers all jar added in lib folder. Or you can add `compile files('libs/org.apache.http.legacy.jar')` – Sandeep Devhare Aug 17 '16 at 13:03
  • I guess you simply can't and shouldn't use both as dependencies, but only the ones you really need. Your error message itself says duplicate entry please try to check correctly – Sandeep Devhare Aug 17 '16 at 13:13

0 Answers0