5

I am currently working on an android app, but whenever I try to load certain jar files I get the following error:

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'. com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/annotation/WorkerThread.class

This is my gradle file

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
    applicationId "company.example.com.mobileapp"
    minSdkVersion 16
    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 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile files('libs/apache-httpcomponents-httpclient.jar')
compile files('libs/apache-httpcomponents-httpcore.jar')
//compile files('libs/java-json.jar')
//compile files('libs/android-support-v4.jar')
compile files('libs/commons-codec-1.10.jar')
compile files('libs/commons-io-2.4.jar')
compile files('libs/commons-lang3-3.4.jar')
}
D.Dimitrioglo
  • 3,413
  • 2
  • 21
  • 41

2 Answers2

3

You are adding this line

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

So remove the redundancy lines

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
}

OR

Remove this line

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

dependencies {
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile files('libs/apache-httpcomponents-httpclient.jar')
compile files('libs/apache-httpcomponents-httpcore.jar')
//compile files('libs/java-json.jar')
//compile files('libs/android-support-v4.jar')
compile files('libs/commons-codec-1.10.jar')
compile files('libs/commons-io-2.4.jar')
compile files('libs/commons-lang3-3.4.jar')
}
Community
  • 1
  • 1
johnrao07
  • 6,690
  • 4
  • 32
  • 55
0

Try cleaning your project.

Build -> Clean Project

Run again after cleaning.

Akeshwar Jha
  • 4,516
  • 8
  • 52
  • 91