Android Gradle compiling commons-io creates duplicate in library tree

前端 未结 4 1601
情深已故
情深已故 2020-12-10 06:44

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

depend         


        
相关标签:
4条回答
  • 2020-12-10 07:19

    It could be possible that other libraries in the project have the commons-io dependency causing duplicate entries.

    See if this helps - Gradle Duplicate Entry: java.util.zip.ZipException

    0 讨论(0)
  • 2020-12-10 07:20

    I know that this thread is old enough, but if someone faces this issue, the reason may be in the artifact itself.

    com.apache.commons:commons-io:XXX has been moved to commons-io:commons-io:XXX and fetching of the old artifact may produce unexpected behavior.

    0 讨论(0)
  • 2020-12-10 07:22

    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'
    }
    
    0 讨论(0)
  • 2020-12-10 07:23

    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

    0 讨论(0)
提交回复
热议问题