Android studio 错误:任务';的执行失败:应用程序:transformClassesWithJarMergingForDebug CopyUtil.class

Android studio 错误:任务';的执行失败:应用程序:transformClassesWithJarMergingForDebug CopyUtil.class,android-studio,gradle,build,Android Studio,Gradle,Build,我在android studio中制作了一个项目,但突然出现了错误 我今天没有把gradle放在build.gradle中,早上我构建项目时它没有问题 Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'. > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate

我在android studio中制作了一个项目,但突然出现了错误

我今天没有把gradle放在build.gradle中,早上我构建项目时它没有问题

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/commons/io/CopyUtils.class
这是我的身材,格雷德尔

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    testCompile 'junit:junit:4.12'
    compile 'com.mobsandgeeks:android-saripaar:2.0.3'
    compile 'com.koushikdutta.ion:ion:2.1.9'
    compile 'gun0912.ted:tedpermission:1.0.2'
    compile 'com.android.support:design:24.+'
    compile 'com.estimote:sdk:0.13.0'
    compile 'jp.wasabeef:glide-transformations:2.0.0'
    compile 'com.afollestad:easyvideoplayer:0.3.0'
    compile 'fm.jiecao:jiecaovideoplayer:4.8.3'
    compile 'com.github.jrvansuita:PickImage:v2.0.0'
    compile 'gun0912.ted:tedbottompicker:1.0.3'
    compile 'com.github.jrvansuita:PickImage:v2.0.0'
    compile 'com.amazonaws:aws-android-sdk-s3:2.+'
    compile 'com.mindorks:placeholderview:0.6.0'

    compile 'com.tsengvn:Typekit:1.0.0'
    compile 'com.github.esafirm:RxDownloader:1.0.1'
    compile 'com.mlsdev.rximagepicker:library:1.1.2'
    compile 'io.reactivex:rxjava:1.0.14'
    compile 'com.kbeanie:image-chooser-library:1.5.2@aar'
    compile 'com.kbeanie:image-chooser-library:1.5.8'
    compile 'io.github.jeancsanchez.photoviewslider:photoviewslider:1.2.0'
    compile 'com.nononsenseapps:filepicker:3.1.0'
    compile 'com.gjiazhe:scrollparallaximageview:1.0'
    compile 'com.droidninja:filepicker:1.0.8'
    compile 'com.mindorks:placeholderview:0.6.1'
    compile 'com.thoughtbot:expandablerecyclerview:1.3'

    compile 'com.android.support:multidex:1.0.0'
}
我对此一无所知


你能帮我解决这个问题吗?

我也有同样的问题,我怀疑新的Android Studio/Gradle版本有问题,因为这个问题是在将Android Studio从2.2.3升级到2.3之后出现的

我用
gradlew app:dependencies
检查了依赖关系树,但commons io似乎没有重复。(见下文)

当我在android studio中使用Ctrl+N搜索类
CopyUtils
时,我得到了两个类:

编辑 我使用find命令对缓存文件夹进行了一些调查,在不同的文件夹中得到了2个commons io JAR:

./.gradle/caches/modules-2/files-2.1/commons-io/commons-io/1.3.2/b6dde38349ba9bb5e6ea6320531ae969985dae5/commons-io-1.3.2.jar

./.gradle/caches/modules-2/files-2.1/org.apache.commons/commons-io/1.3.2/b6dde38349ba9bb5e6ea6320531ae969985dae5/commons-io-1.3.2.jar

编辑2 commons io包含自身,导致重复的类(???) 如依赖关系树中所示:

+--- org.apache.commons:commons-io:1.3.2
|    \--- commons-io:commons-io:1.3.2
我真的不知道为什么,这个问题以前也没有出现过。 尽管如此,修改依赖项还是解决了我的问题:

compile('org.apache.commons:commons-io:1.3.2'){
    exclude module: 'commons-io'
}
依赖关系树:

compile - Classpath for compiling the main sources.
+--- io.realm:realm-android-library:2.2.1
|    +--- io.realm:realm-annotations:2.2.1
|    \--- com.getkeepsafe.relinker:relinker:1.2.2
+--- io.realm:realm-annotations:2.2.1
+--- commons-httpclient:commons-httpclient:3.1
|    +--- commons-logging:commons-logging:1.0.4
|    \--- commons-codec:commons-codec:1.2
+--- slide:slide-webdavlib:2.1
|    +--- commons-httpclient:commons-httpclient:2.0.2 -> 3.1 (*)
|    +--- jdom:jdom:1.0
|    \--- de.zeigermann.xml:xml-im-exporter:1.1
+--- org.htmlparser:htmlparser:1.6
+--- org.apache.commons:commons-io:1.3.2
|    \--- commons-io:commons-io:1.3.2
+--- net.rdrei.android.dirchooser:library:3.2
|    +--- com.google.auto.value:auto-value:1.1
|    +--- com.github.frankiesardo:auto-parcel:0.3.1
|    +--- com.android.support:appcompat-v7:22.2.1 -> 25.3.0
|    |    +--- com.android.support:support-annotations:25.3.0
|    |    +--- com.android.support:support-v4:25.3.0
|    |    |    +--- com.android.support:support-compat:25.3.0
|    |    |    |    \--- com.android.support:support-annotations:25.3.0
|    |    |    +--- com.android.support:support-media-compat:25.3.0
|    |    |    |    +--- com.android.support:support-annotations:25.3.0
|    |    |    |    \--- com.android.support:support-compat:25.3.0 (*)
|    |    |    +--- com.android.support:support-core-utils:25.3.0
|    |    |    |    +--- com.android.support:support-annotations:25.3.0
|    |    |    |    \--- com.android.support:support-compat:25.3.0 (*)
|    |    |    +--- com.android.support:support-core-ui:25.3.0
|    |    |    |    +--- com.android.support:support-annotations:25.3.0
|    |    |    |    \--- com.android.support:support-compat:25.3.0 (*)
|    |    |    \--- com.android.support:support-fragment:25.3.0
|    |    |         +--- com.android.support:support-compat:25.3.0 (*)
|    |    |         +--- com.android.support:support-media-compat:25.3.0 (*)
|    |    |         +--- com.android.support:support-core-ui:25.3.0 (*)
|    |    |         \--- com.android.support:support-core-utils:25.3.0 (*)
|    |    +--- com.android.support:support-vector-drawable:25.3.0
|    |    |    +--- com.android.support:support-annotations:25.3.0
|    |    |    \--- com.android.support:support-compat:25.3.0 (*)
|    |    \--- com.android.support:animated-vector-drawable:25.3.0
|    |         \--- com.android.support:support-vector-drawable:25.3.0 (*)
|    +--- com.gu:option:1.3
|    \--- com.android.support:support-annotations:22.2.1 -> 25.3.0
+--- com.googlecode.juniversalchardet:juniversalchardet:1.0.3
+--- project :uploadservice-dav
|    +--- commons-net:commons-net:3.5
|    +--- project :uploadservice
|    |    +--- com.android.support:appcompat-v7:24.2.1 -> 25.3.0 (*)
|    |    +--- com.android.support:support-v4:24.2.1 -> 25.3.0 (*)
|    |    +--- com.squareup.okhttp3:okhttp:3.4.1
|    |    |    \--- com.squareup.okio:okio:1.9.0
|    |    +--- com.squareup.okhttp3:okhttp-urlconnection:3.4.1
|    |    |    \--- com.squareup.okhttp3:okhttp:3.4.1 (*)
|    |    \--- com.squareup.okhttp3:logging-interceptor:3.4.1
|    |         \--- com.squareup.okhttp3:okhttp:3.4.1 (*)
|    +--- com.squareup.okhttp3:okhttp:3.4.1 (*)
|    +--- com.squareup.okhttp3:logging-interceptor:3.4.1 (*)
|    +--- org.apache.jackrabbit:jackrabbit-webdav:2.10.1
|    |    +--- org.slf4j:slf4j-api:1.6.6 -> 1.7.4
|    |    +--- commons-httpclient:commons-httpclient:3.1 (*)
|    |    \--- org.slf4j:jcl-over-slf4j:1.7.4
|    |         \--- org.slf4j:slf4j-api:1.7.4
|    \--- org.apache.commons:commons-lang3:3.5
+--- com.google.code.gson:gson:2.7
+--- com.android.support:multidex:1.0.1
+--- com.android.support:appcompat-v7:25.3.0 (*)
+--- com.android.support:cardview-v7:25.3.0
|    \--- com.android.support:support-annotations:25.3.0
+--- com.android.support:design:25.3.0
|    +--- com.android.support:support-v4:25.3.0 (*)
|    +--- com.android.support:appcompat-v7:25.3.0 (*)
|    +--- com.android.support:recyclerview-v7:25.3.0
|    |    +--- com.android.support:support-annotations:25.3.0
|    |    +--- com.android.support:support-compat:25.3.0 (*)
|    |    \--- com.android.support:support-core-ui:25.3.0 (*)
|    \--- com.android.support:transition:25.3.0
|         +--- com.android.support:support-annotations:25.3.0
|         \--- com.android.support:support-v4:25.3.0 (*)
+--- com.android.support:gridlayout-v7:25.3.0
|    +--- com.android.support:support-compat:25.3.0 (*)
|    \--- com.android.support:support-core-ui:25.3.0 (*)
+--- com.android.support:mediarouter-v7:25.3.0
|    +--- com.android.support:appcompat-v7:25.3.0 (*)
|    \--- com.android.support:palette-v7:25.3.0
|         +--- com.android.support:support-compat:25.3.0 (*)
|         \--- com.android.support:support-core-utils:25.3.0 (*)
+--- com.android.support:palette-v7:25.3.0 (*)
+--- com.android.support:recyclerview-v7:25.3.0 (*)
+--- com.android.support:support-annotations:25.3.0
+--- com.android.support:support-v13:25.3.0
|    +--- com.android.support:support-annotations:25.3.0
|    \--- com.android.support:support-v4:25.3.0 (*)
+--- com.android.support:support-v4:25.3.0 (*)
+--- com.scottyab:secure-preferences-lib:0.1.4
|    \--- com.scottyab:aes-crypto:0.0.4
+--- com.facebook.stetho:stetho:1.4.1
|    +--- commons-cli:commons-cli:1.2
|    \--- com.google.code.findbugs:jsr305:2.0.1
+--- com.uphyca:stetho_realm:2.0.0
+--- com.github.gabrielemariotti.cards:cardslib-core:2.1.0
|    +--- com.android.support:support-annotations:22.1.1 -> 25.3.0
|    +--- com.android.support:support-v4:22.1.1 -> 25.3.0 (*)
|    \--- com.android.support:cardview-v7:22.1.1 -> 25.3.0 (*)
+--- com.github.gabrielemariotti.cards:cardslib-recyclerview:2.1.0
|    +--- com.android.support:support-annotations:22.1.1 -> 25.3.0
|    +--- com.android.support:recyclerview-v7:22.1.1 -> 25.3.0 (*)
|    \--- com.github.gabrielemariotti.cards:cardslib-core:2.1.0 (*)
+--- com.afollestad.material-dialogs:core:0.9.0.1
|    +--- com.android.support:recyclerview-v7:24.1.1 -> 25.3.0 (*)
|    +--- com.android.support:support-v4:24.1.1 -> 25.3.0 (*)
|    +--- me.zhanghai.android.materialprogressbar:library:1.1.7
|    |    +--- com.android.support:appcompat-v7:24.0.0 -> 25.3.0 (*)
|    |    \--- com.android.support:support-annotations:24.0.0 -> 25.3.0
|    +--- com.android.support:appcompat-v7:24.1.1 -> 25.3.0 (*)
|    \--- com.android.support:support-annotations:24.1.1 -> 25.3.0
+--- com.afollestad.material-dialogs:commons:0.9.0.1
|    +--- com.afollestad.material-dialogs:core:0.9.0.1 (*)
|    \--- com.android.support:appcompat-v7:24.1.1 -> 25.3.0 (*)
+--- com.gu:option:1.3
+--- com.nononsenseapps:filepicker:3.1.0
|    +--- com.android.support:appcompat-v7:24.2.1 -> 25.3.0 (*)
|    +--- com.android.support:support-v4:24.2.1 -> 25.3.0 (*)
|    \--- com.android.support:recyclerview-v7:24.2.1 -> 25.3.0 (*)
+--- ch.acra:acra:4.9.1
|    +--- com.android.support:support-v4:24.1.1 -> 25.3.0 (*)
|    \--- com.android.support:support-annotations:24.1.1 -> 25.3.0
+--- com.github.bumptech.glide:glide:3.7.0
+--- com.github.bumptech.glide:okhttp3-integration:1.4.0
\--- com.squareup.okhttp3:okhttp:3.4.1 (*)

org.apache.commons:commons io:1.3.2的部署是一个错误,最终通过将org.apache.commons:commons io:1.3.2的POM重新定位为使用commons io:commons io:1.3.2来修复。错误可能是试图将Commons IO库迁移到Maven GroupID的当前命名约定

configurations.all {
    resolutionStrategy.dependencySubstitution {
        substitute module('org.apache.commons:commons-io:1.3.2') with module('commons-io:commons-io:1.3.2')
    }
}

在运行之前,您是否尝试过清理和重建项目?@ScottS是的,我尝试过