Gradle duplicate files during packaging - messages.properties by JodaTime

I recently replaced Java Date classes with Joda DateTime classes in my Android app. I am using Jackson to parse json . I added the following lines to the 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. duplicate files during packaging of APK error message. He also suggested the following option.

 android { packagingOptions { exclude 'org/joda/time/format/messages_da.properties' } } 

JodaTime has files such as "messages_da.properties", "messages_fr.properties". I believe that they are used to provide language-based formatting.

My hunch is that these files should not be excluded. If the experts there can provide a solution for this, it would be great

+8
source share
3 answers

This is actually a problem that arises from several joda-time dependencies in your project.

To fix this, you must exclude any "duplicate" joda-time from any dependency in your project that contains a "duplicate" joda-time .

To find out which dependencies include "repeating" joda-time , use the ./gradlew app:dependencies ./gradlew app:dependencies to have the ./gradlew app:dependencies complete ./gradlew app:dependencies graph. Then browse through the list of dependencies and find those that include a "duplicate" joda-time . Then exclude joda-time from any dependency that includes its "duplicate". After that, your application will work fine.

An 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 right way to handle dependency conflicts.

+6
source

I solved this problem for example

 android { packagingOptions { exclude 'org/joda/time/format/*.properties' } } 
+4
source

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' } } 
+3
source

All Articles