android-studio - 错误:任务':app:transformClassesWithJarMergingForDebug CopyUtil.class的执行失败

标签 android-studio gradle build

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

我今天没有在build.gradle中添加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

这是我的build.gradle
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类时,我实际上得到了2个类:
Ctrl+N search CopyUtils
编辑
我用find命令调查了缓存文件夹,并在不同的文件夹中得到了2个commons-io jar:

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



./.gradle/caches/modules-2/files-2.1/org.apache.commons/commons-io/1.3.2/b6dde38349ba9bb5e6ea6320531eae969985dae5/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 (*)

关于android-studio - 错误:任务':app:transformClassesWithJarMergingForDebug CopyUtil.class的执行失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42943755/

相关文章:

android-studio - 模拟器不会在 android studio 中启动数小时

java - Gradle 模块构建顺序

c++ - Incredibuild 不是很快

android - 有没有办法在 Android Studio 中完全隐藏 Android 窗口?

库的 Android Studio consumerProguardFiles 不起作用

android - 在Android的Build Intermediate Androidmainfest.xml中添加了android.support.v7.widget.TestActivity

build - 如何自动运行参数化的 Jenkins 作业

java - 构建允许在不同二进制文件之间共享模块的系统

java - Android 在应用程序上下文中保存图像

android - 基于其他 flavor 的 Gradle flavor