Android, Gradle and duplicate files error during packaging

拜拜、爱过 提交于 2019-12-04 14:47:18

For others, here a quick workaround until Gradle will add packaging options with proper duplicate strategies:

android.applicationVariants.all { variant-> variant.assemble.doFirst { exec { executable "sh" args "-c", "find ~/.gradle/caches/ -iname 'json-schema-validator*.jar' -exec zip -d '{}' 'draftv3/schema' \\;" args "-c", "find ~/.gradle/caches/ -iname 'json-schema-validator*.jar' -exec zip -d '{}' 'draftv4/schema' \\;" } } }

By explicitly mentioning the draftv/schema files in the build.graddle file we can resolve this issue.

    android {

    ...

        packagingOptions {

            ...

            pickFirst 'draftv3/schema'
            pickFirst 'draftv4/schema'

        }
    }

Try the following to only exclude draftv3/schema from your dependency:

dependencies {
   compile('com.github.fge:json-schema-validator:2.1.8') {
       exclude 'draftv3/schema'
   }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!