Only some users reporting “Resource Not Found” err

2019-02-07 17:21发布

I am seeing a a couple of errors coming up on Crittercism (Crash reporting service) for my published Android app. The trace is the following:

0   java.io.IOException: Resource not found: "org/joda/time/tz/data/ZoneInfoMap" ClassLoader: dalvik.system.PathClassLoader@45908320
1    at org.joda.time.tz.ZoneInfoProvider.openResource(ZoneInfoProvider.java:211)
2    at org.joda.time.tz.ZoneInfoProvider.<init>(ZoneInfoProvider.java:123)
3    at org.joda.time.tz.ZoneInfoProvider.<init>(ZoneInfoProvider.java:82)
4    at org.joda.time.DateTimeZone.getDefaultProvider(DateTimeZone.java:462)
5    at org.joda.time.DateTimeZone.setProvider0(DateTimeZone.java:416)
6    at org.joda.time.DateTimeZone.<clinit>(DateTimeZone.java:115)
7    at org.joda.time.chrono.GregorianChronology.<clinit>(GregorianChronology.java:71)
8    at org.joda.time.chrono.ISOChronology.<clinit>(ISOChronology.java:66)
9    at org.joda.time.base.BaseDateTime.<init>(BaseDateTime.java:61)
10   at org.joda.time.DateTime.<init>(DateTime.java:155)

Searching shows this this is usually a compiling problem (Usually that the Joda Time Library was not added to the build path or something), but then why would only about 4 users out of a couple thousand see this error?

My only guess is that someone is trying to decompile the app to pirate it (Its a fairly popular paid app), and sees this error when they incorrectly re-compiled. In that case I am glad they are seeing errors and I dont need to worry about this.

The other weird thing is that the code causing the problem was surrounded by a try/catch, which didnt seem to catch it:

try {
    DateTime dt = new DateTime();
    DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
    return fmt.print(dt);
} catch (Exception e) {
    //Report issue to Analytics service
} 

Which to me, makes it seem even more unlikely that this error would show up on Crittercism, since it should've been caught. Can anyone explain this?

3条回答
做自己的国王
2楼-- · 2019-02-07 17:49

I see similar, infrequent reports from a popular free app. I haven't reproduced it so far. There are various references to this problem sprinkled around the web, not all involving Android.

One clue: the ZoneInfoMap is a resource file in the original jar, not a class. So if any of the various app markets was stripping out non-class information (e.g. unjar then re-jar), ZoneInfoMap would be a candidate. Likewise, if any classloader utility had an issue, for security or stupidity, with non-class resources, ZoneInfoMap would be a candidate.

Another angle: could the problematic runtime environment have its own joda-time jar earlier in the classpath, one that lacks a /data/ segment?

Bottom line: seems like this is another example of the Wild West of Android, one that I've learned to ignore until I can find a repro.

查看更多
放我归山
3楼-- · 2019-02-07 18:02

This can happen in the case you miss initialization:

JodaTimeAndroid.init(this);
查看更多
我只想做你的唯一
4楼-- · 2019-02-07 18:07

I have had the same problem and after a good deal of digging searching on google I figured it out. The ZoneInfoMap file is created by running jodaTime (ZoneInfoCompiler) with the arguments:

    -dst src\org\joda\time\tz\data src\org\joda\time\tz\src\africa 
src\org\joda\time\tz\src\antarctica src\org\joda\time\tz\src\asia 
src\org\joda\time\tz\src\australasia src\org\joda\time\tz\src\backward 
src\org\joda\time\tz\src\etcetera src\org\joda\time\tz\src\europe 
src\org\joda\time\tz\src\northamerica src\org\joda\time\tz\src\pacificnew 
src\org\joda\time\tz\src\southamerica src\org\joda\time\tz\src\systemv

This will add all the timezone to the jodaTimer, you can create more time Zone areas I believe if you know how as well, and you do not have to include all of them if you don't need all of them.

why it crashes with that error is because it is looking for a file that is not there. Not sure exactly why try catch is not working but I suspect it has something to do with the fact that the jodaTimer is a JAR library (mine was at least)?

Not sure if this is how it is meant to be done or if there is a better solution but that's what i did and it works for me perfectly now.

references that helped m come to this conclusion: http://joda-interest.219941.n2.nabble.com/How-to-run-Joda-time-s-test-Resource-Not-Found-exception-td5913668.html http://sourceforge.net/p/joda-time/discussion/337835/thread/2798a578/

I hope this helps.

查看更多
登录 后发表回答