任务执行失败:app:transformClassesWithJarMergingForDebug

时间:2016-06-29 05:52:41

标签: java android gradle

我目前正在开发一个Android应用程序,但每当我尝试加载某些jar文件时,我都会收到以下错误:

  

错误:任务执行失败   ':应用程序:transformClassesWithJarMergingForDebug'。   com.android.build.api.transform.TransformException:   java.util.zip.ZipException:重复条目:   机器人/支撑/注解/ WorkerThread.class

这是我的gradle文件

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')
}

2 个答案:

答案 0 :(得分:3)

您正在添加此行

  

编译fileTree(dir:'libs',包括:['* .jar'])

删除冗余线

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'
}

  

删除此行

     

编译fileTree(dir:'libs',包括:['* .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')
}

答案 1 :(得分:0)

尝试清理项目。

Build -> Clean Project

清洁后再次运行。