Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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:

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

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

enter image description here

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
347 views
Welcome To Ask or Share your Answers For Others

1 Answer

There is an option to fix it on gradle dependency resolution level

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

Reason of the conflict is that org.apache.commons:commons-io:1.3.2 was pushed by mistake https://stackoverflow.com/a/37421794/624706

You can see where dependency is coming from with

gradle :main:dependencyInsight --configuration compile --dependency commons-io


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...