35

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?

4

3 回答 3

80

如果您错过初始化,可能会发生这种情况:

JodaTimeAndroid.init(this);
于 2015-03-07T17:32:43.043 回答
0

我从一个流行的免费应用程序中看到类似的、不常见的报告。到目前为止我还没有复制它。网络上散布着各种 关于这个问题的参考资料,但并非都涉及 Android。

一条线索:ZoneInfoMap 是原始 jar 中的资源文件,而不是类。因此,如果各种应用程序市场中的任何一个都在剥离非类信息(例如 unjar 然后 re-jar),ZoneInfoMap 将是一个候选者。同样,如果任何类加载器实用程序对于非类资源存在安全性或愚蠢性问题,ZoneInfoMap 将是一个候选者。

另一个角度:有问题的运行时环境是否可以在类路径的早期有自己的 joda-time jar,一个缺少 /data/ 段的 jar?

底线:这似乎是 Android 狂野西部的另一个例子,我学会了忽略它,直到我找到一个复制品。

于 2014-01-29T23:54:27.250 回答
0

我也遇到了同样的问题,在谷歌上进行了大量的挖掘搜索后,我想通了。ZoneInfoMap 文件是通过使用以下参数运行 jodaTime (ZoneInfoCompiler) 创建的:

    -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

这会将所有时区添加到 jodaTimer,如果您也知道如何创建更多时区,我相信您可以创建更多时区,如果您不需要所有时区,则不必包括所有时区。

为什么它因该错误而崩溃是因为它正在寻找一个不存在的文件。不确定为什么 try catch 不起作用,但我怀疑这与 jodaTimer 是一个 JAR 库(至少我的库是)这一事实有关?

不确定这是否是它的意思,或者是否有更好的解决方案,但这就是我所做的,它现在对我来说非常有效。

帮助我得出这个结论的参考资料: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/

我希望这有帮助。

于 2015-05-12T13:47:16.143 回答