1

The ThreeTenABP README instructs users to isert a call to AndroidThreeTen.init() into their application’s onCreate() method. And yes, that’s the (supposedly faster) Android adaptation of ThreeTenBP, not the original (fully portable) ThreeTenBP.

However, if I omit the call, my app seems to run fine and without any obvious errors. Is this method just there to speed up things, anticipating a possibly lengthy initialization so it won’t slow you down on first use (eager vs. lazy initialization)? Or do I risk getting incorrect results if I don’t initialize ThreeTenABP properly?

user149408
  • 5,385
  • 4
  • 33
  • 69
  • 2
    I'm not confident enough to say for sure (thus, no answer), but I think you lose the benefit of using the optimized port if you don't have this call. The call registers the optimized ZoneRulesProvider which is probably the reason ThreeTenABP is faster than plain ThreeTenBP in the first place. Also note that starting with Android 8 there's a *native* `java.time` implementation which should perform even better as it uses the system-native time zone database. – Joachim Sauer Jul 09 '19 at 20:39
  • Yep, I’m aware of `java.time` in Android 8+, I’m just not aware of a portable way to switch between the two implementations (given that the code is in a portable library, which needs to support Android 4.4+ as well as JRE). – user149408 Jul 09 '19 at 21:06

1 Answers1

1

This question describes an error resulting from failure to initialize the library.

Main takeaway: if you fail to initialize ThreeTenABP, certain method calls (those that rely upon time zone data) will throw an exception.

Not sure what happens if you have tested each ThreeTenABP call in your code and have made sure none of them throws an exception. This is most likely an unsupported configuration.

user149408
  • 5,385
  • 4
  • 33
  • 69