Gradle duplicate files during packing - messages.properties of JodaTime
My dirty solution:
android {
packagingOptions {
exclude 'META-INF/maven/joda-time/joda-time/pom.properties'
exclude 'META-INF/maven/joda-time/joda-time/pom.xml'
pickFirst 'org/joda/time/format/messages.properties'
pickFirst 'org/joda/time/format/messages_cs.properties'
pickFirst 'org/joda/time/format/messages_da.properties'
pickFirst 'org/joda/time/format/messages_de.properties'
pickFirst 'org/joda/time/format/messages_en.properties'
pickFirst 'org/joda/time/format/messages_es.properties'
pickFirst 'org/joda/time/format/messages_fr.properties'
pickFirst 'org/joda/time/format/messages_it.properties'
pickFirst 'org/joda/time/format/messages_ja.properties'
pickFirst 'org/joda/time/format/messages_no.properties'
pickFirst 'org/joda/time/format/messages_nl.properties'
pickFirst 'org/joda/time/format/messages_pl.properties'
pickFirst 'org/joda/time/format/messages_pt.properties'
pickFirst 'org/joda/time/format/messages_ru.properties'
pickFirst 'org/joda/time/format/messages_tr.properties'
}
}
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'
}
}