dlew/joda-time-android

java.io.IOException: Resource not found: "org/joda/time/tz/data/ZoneInfoMap"

Jomme5 opened this issue · 5 comments

Got this error when executing:
DateTime.now().toLocalTime().toString()

I did initialization:
JodaTimeAndroid.init(this);

  1. The initialization happens in MainActivity.java
  2. The actual toLocalTime-call happens in an interval worker-class(possibly another thread).

I copied the initialization from the MainActivity-class to the worker-class like:
JodaTimeAndroid.init(getApplicationContext())
which then works.
So you have to do an initialization in every class or every worker-thread?

dlew commented

It should be valid for the entire application context.

Is it possible that your worker is in another process? In that case you would run into trouble.

I would also think that JodaTimeAndroid.init(this); is for the entire app-context.

I actually make use of PeriodicWorkRequest, witch needs a workerclass. So, it does run in the same application, but maybe on a different thread. However, I'm in doubt about that, since PeriodicWorkRequest makes use of the Workmanager-service. And so the worker-class is maybe called from another system process.

I also tried with JodaTimeAndroid.init(getApplicationContext()) in MainActivity, in stead of JodaTimeAndroid.init(this) but got the same results.

dlew commented

Threading should make no difference on whether this works or not.

If you have a sample app showing the problem, I could dig into it. The basic idea, though, is that we need to provide the Context to the timezone provider. If you're in some sandboxed situation, then the first initialization won't reach there.

dlew commented

Closing for lack of reproduction. If you have a repro, I'd be happy to look into it more.