Reputation: 181
I want to use the json-schema-validator in my Android project like this:
dependencies {
compile 'com.github.fge:json-schema-validator:2.1.8'
}
Unfortunately Gradle stops packaging due to this file duplicate error:
Path in archive: draftv3/schema
Origin 1: /Users/andrej/.gradle/caches/modules-2/files-2.1/com.github.fge/json-schema-validator/2.1.8/4c2a5be8ce86c2338561a651d7d22fb4c4a8763d/json-schema-validator-2.1.8.jar
Origin 2: /Users/andrej/.gradle/caches/modules-2/files-2.1/com.github.fge/json-schema-core/1.1.9/4ead9ba3fb3bde69d93f738042d12a9e60e41645/json-schema-core-1.1.9.jar
I know I can ignore the file like this:
packagingOptions {
exclude 'draftv3/schema'
}
But the file is used by json-schema-validator and json-validator-core, so it is required in the resulting APK.
How can I force Gradle to proceed packaging while keeping one of the two versions of this file (they are equal)?
Thanks, Andrej
Upvotes: 5
Views: 1038
Reputation: 1017
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'
}
}
Upvotes: 3
Reputation: 181
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' \\;"
}
}
}
Upvotes: 1
Reputation: 2864
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'
}
}
Upvotes: 0