JakeWharton / ThreeTenABP

An adaptation of the JSR-310 backport for Android.
Apache License 2.0
3.55k stars 133 forks source link

ThreeTenABP as JAR? #62

Closed cleemansen closed 6 years ago

cleemansen commented 6 years ago

Hello,

I am working w/ multiple gradle modules in my android app. One of them is a pure java module. As I understand it a Java-Module can not depend on a aar-dependency. Trying to integrate ThreeTenADB into my Java-Module fails w/ build-error:

Error:Module 'xxxxxx' depends on one or more Android Libraries but is a jar

Thanks!

JakeWharton commented 6 years ago

You can depend on the normal https://github.com/ThreeTen/threetenbp library and then use a Gradle resolution strategy dependency substitution to replace that dependency with the ABP one for Android modules (or just the app module).

cleemansen commented 6 years ago

Thank you for that hint! I really appreciate it!

I added to the app/build.gradle:

configurations {
  compile.resolutionStrategy {
    dependencySubstitution {
      substitute module('org.threeten:threetenbp:1.3.6') with module('com.jakewharton.threetenabp:threetenabp:1.0.5')
    }
  }
}

Gradle build is now fine. Unfortunately my app doesn't start anymore. I am not sure if it is related to my first question. My I ask you again for any tips w/ the following exception during startup:

Caused by: org.threeten.bp.zone.ZoneRulesException: Unable to register zone as one already registered with that ID: Asia/Aden, currently loading from provider: TZDB
                                                                                     at org.threeten.bp.zone.ZoneRulesProvider.registerProvider0(ZoneRulesProvider.java:205)
                                                                                     at org.threeten.bp.zone.ZoneRulesProvider.registerProvider(ZoneRulesProvider.java:190)
                                                                                     at com.jakewharton.threetenabp.AndroidThreeTen.init(AndroidThreeTen.java:40)
                                                                                     at com.jakewharton.threetenabp.AndroidThreeTen.init(AndroidThreeTen.java:16)