0

when i try to add the jar files to my project i got the error like Error:Execution failed for task

':app:transformClassesWithJarMergingForDebug'. > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/http/annotation/Immutable.class in android studio

build.gradle

ultConfig {
        applicationId "com.syzygy.extreme.uploadexample"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile files('libs/apache-httpcomponents-httpclient.jar')
    compile files('libs/httpcore-4.3.3.jar')
    compile files('libs/httpmime-4.0.jar')
}
IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198
  • post your `build.gradle` – IntelliJ Amiya Mar 10 '16 at 09:50
  • `duplicate entry` same library calling one more time – IntelliJ Amiya Mar 10 '16 at 09:51
  • dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.1.1' compile 'com.android.support:design:23.1.1' compile files('libs/apache-httpcomponents-httpclient.jar') compile files('libs/httpcore-4.3.3.jar') compile files('libs/httpmime-4.0.jar') } – krishnaveni Mar 10 '16 at 09:57
  • comment this line `compile files('libs/apache-httpcomponents-httpclient.jar')` – IntelliJ Amiya Mar 10 '16 at 10:02
  • then `Clean-Rebuild-Run` .Let me inform . – IntelliJ Amiya Mar 10 '16 at 10:02
  • Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'. > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/http/annotation/Immutable.class – krishnaveni Mar 10 '16 at 10:10
  • @krishnaveni, check my answer.. it is 100% working – Nik Patel Mar 10 '16 at 10:11
  • @krishnaveni call `compile 'org.apache.httpcomponents:httpclient-android:4.3.5'` instead of your 3 library .http://stackoverflow.com/questions/24761347/which-httpmime-version-can-i-use-with-androids-httpclient – IntelliJ Amiya Mar 10 '16 at 10:16
  • Error:(9, 30) error: cannot find symbol class HttpClient Error:(10, 38) error: cannot find symbol class HttpPost Error:(11, 35) error: cannot find symbol class DefaultHttpClient Error:(47, 17) error: cannot find symbol class HttpClient Error:(47, 45) error: cannot find symbol class DefaultHttpClient Error:(48, 17) error: cannot find symbol class HttpPost Error:(48, 41) error: cannot find symbol class HttpPost – krishnaveni Mar 10 '16 at 10:33
  • please resolve my problem..iam not able to use the http client and request – krishnaveni Mar 10 '16 at 10:35
  • @ krishnaveni, have u used my code(dependencies) ? – Nik Patel Mar 10 '16 at 10:42
  • yeap..i have used..i got the warning like useLibrary 'org.apache.http.legacy while build the project – krishnaveni Mar 10 '16 at 10:44
  • @krishnaveni add `compile 'org.apache.httpcomponents:httpcore:4.4.1' compile 'org.apache.httpcomponents:httpclient:4.5'` – IntelliJ Amiya Mar 10 '16 at 11:56

1 Answers1

-1

Try this out for http core and mime. 100% working

android {

    repositories {
        mavenCentral()
    }
    android {
        useLibrary 'org.apache.http.legacy'
    }
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/LGPL2.1'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/notice.txt'
    }
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

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

dependencies {


    compile fileTree(dir: 'libs', include: ['*.jar'])

    compile group: 'org.apache.httpcomponents', name: 'httpclient-android', version: '4.3.5.1'
    compile('org.apache.httpcomponents:httpmime:4.3') {
        exclude module: "httpclient"
    }

    compile 'com.android.support:appcompat-v7:23.1.0'
    compile 'com.android.support:design:23.1.0'

    testCompile 'junit:junit:4.12'


}
Nik Patel
  • 627
  • 7
  • 21
  • hi @NikPatel your reply is useful to me can u please mention that how to change version '4.3.5.1' i am try to use update library for that i am try to update client library version like '4.5.1' but it will not excepted.Thank you – Jayman Jani Apr 01 '16 at 13:24