打包过程中 Android、Gradle 和重复文件错误 [英] Android, Gradle and duplicate files error during packaging
问题描述
我想像这样在我的 Android 项目中使用 json-schema-validator:
I want to use the json-schema-validator in my Android project like this:
依赖项{编译'com.github.fge:json-schema-validator:2.1.8'}
不幸的是,由于此文件重复错误,Gradle 停止打包:
Unfortunately Gradle stops packaging due to this file duplicate error:
归档路径:draftv3/schema起源 1:/Users/andrej/.gradle/caches/modules-2/files-2.1/com.github.fge/json-schema-validator/2.1.8/4c2a5be8ce86c2338561a651d7d22fb4c4a8763d/json-schema-validator-validator.来源 2:/Users/andrej/.gradle/caches/modules-2/files-2.1/com.github.fge/json-schema-core/1.1.9/4ead9ba3fb3bde69d93f738042d12a9e60e41645/json-schema-core.jar1
我知道我可以像这样忽略文件:
I know I can ignore the file like this:
packagingOptions {排除draftv3/schema"}
但是该文件被json-schema-validator 和json-validator-core 使用,因此在生成的APK 中是必需的.
But the file is used by json-schema-validator and json-validator-core, so it is required in the resulting APK.
如何强制 Gradle 进行打包,同时保留此文件的两个版本之一(它们是相同的)?
How can I force Gradle to proceed packaging while keeping one of the two versions of this file (they are equal)?
谢谢,安德烈
推荐答案
通过在 build.graddle 文件中明确提及draftv/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'
}
}
这篇关于打包过程中 Android、Gradle 和重复文件错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!