I replaced Java
's Date
classes with Joda
's DateTime
classes recently in my Android app. I use Jackson
for parsing json
. I added the following lines to my build.gradle file
compile com.fasterxml.jackson.datatype:jackson-datatype-joda:2.4.3
compile net.danlew:android.joda:2.7.1
It broke my build. The error message is duplicate files during packaging of APK
. It also suggested the following option
android {
packagingOptions {
exclude 'org/joda/time/format/messages_da.properties'
}
}
There are many such files like that in JodaTime like "messages_da.properties", "messages_fr.properties". I believe those are used to provide locale based formatting.
My hunch says that these files should not be excluded. If experts out there can provide a solution for this, it would be great
This is actually an issue that results from depending on multiple joda-time
modules in your project.
To fix this, you should exclude any duplicate joda-time
module(s) from any dependency in your project that contains a duplicate joda-time
module.
To find out what dependencies are including the duplicate joda-time
, use the command ./gradlew app:dependencies
to list your complete dependency graph. Then look through the list of dependencies and find the ones that includes the duplicate joda-time
module. Then exclude joda-time
from any dependency that includes a duplicate of it. After doing this your app will build fine.
Example of how to exclude joda-time
from a dependency:
// An offending dependency that contains a duplicate joda-time.
compile('com.some.project:some-module:0.1') {
// Exclude joda-time from this dependency to remove the errors.
exclude module: 'joda-time'
}
This is the correct way to handle dependency conflicts.
I solved this issue like
android {
packagingOptions {
exclude 'org/joda/time/format/*.properties'
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With