Joda-Time 2.1 and Android - NoClassDefFoundError

ε祈祈猫儿з 提交于 2019-12-12 17:24:10

问题


Trying to use DateTime in an Android app (API 15) but get the following in logcat:

E/dalvikvm(794): Unable to resolve Lorg/joda/time/base/AbstractInstant; annotation class 1383
D/AndroidRuntime(794): Shutting down VM
W/dalvikvm(794): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
E/AndroidRuntime(794): FATAL EXCEPTION: main
E/AndroidRuntime(794): java.lang.NoClassDefFoundError: org/joda/convert/ToString
E/AndroidRuntime(794):  at java.lang.reflect.Method.getDeclaredAnnotations(Native Method)
E/AndroidRuntime(794):  at java.lang.reflect.Method.getDeclaredAnnotations(Method.java:267)
E/AndroidRuntime(794):  at com.fasterxml.jackson.databind.introspect.AnnotatedClass._addMixUnders(AnnotatedClass.java:999)
....

I have a /libs directory and it has joda-time-2.1.jar. Am I missing something obvious?


I should have looked more carefully at the error stack - in particular the line: java.lang.NoClassDefFoundError: org/joda/convert/ToString

That is from the jar joda-convert, not joda-time and the joda-convert jar file was NOT in my libs directory.

Note: There doesn't seem to be any need to explicitly export the jar


回答1:


You need to add the joda-convert.jar to your libs folder. Download the jar from http://sourceforge.net/projects/joda-convert/files/joda-convert/




回答2:


You should use joda-time-android. This is jodatime library adapted for android.



来源:https://stackoverflow.com/questions/13678147/joda-time-2-1-and-android-noclassdeffounderror

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!