Android Gradle编译commons-io会在库树中创建副本 [英] Android Gradle compiling commons-io creates duplicate in library tree

查看:128
本文介绍了Android Gradle编译commons-io会在库树中创建副本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建并维护一个旧的应用程序,但无法通过构建阶段。在我的 app / build.gradle 文件中,我有

I'm trying to build and maintain an old application for work but I can't get past the build phase. In my app/build.gradle file I have

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.apache.commons:commons-io:1.3.2'
    //some more libraries compiled as well
}

但是在尝试执行时遇到以下错误:

but get the following error when trying to execute:


错误:任务':myApp'的执行失败。
com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:org / apache / commons / io / CopyUtils.class

Error:Execution failed for task ':myApp'. com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/commons/io/CopyUtils.class

这几乎可以肯定是因为当我编译jar时,在我的External Libraries树的顶部,会生成这个消息:

This is almost certainly because when I compile that jar, at the top of my External Libraries tree, this is generated:

为什么会发生这种情况,我该如何让它停下来才能完成构建?

Why is this happening, and how can I get it to stop so I can complete the build?

推荐答案

有一种简单的方法可以排除双重类。首先,你需要找出哪些依赖是造成的,如果你知道使用这段代码:

There is a simple way to exclude the double classes. At first you need to find out which dependency is causing that if you know that use this code:

compile('com.example:some-dependency:4.2') {
    exclude module: 'commons-io'
}

这篇关于Android Gradle编译commons-io会在库树中创建副本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆