乔达时2.1和Android - 的NoClassDefFoundError乔达时、NoClassDefFoundError、Android

2023-09-07 12:59:05 作者:回眸一笑百妹疯罒▽罒

尝试使用的DateTime 在一个Android应用程序(API 15),但得到的的logcat 如下:

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)
....

我有一个/ libs目录,它有乔达时间,2.1.jar。我失去了一些东西明显?

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

我应该多看仔细错误堆栈 - 尤其是该行: java.lang.NoClassDefFoundError的:组织/乔达/转换/的ToString

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

这是从罐子里乔达-转换,不乔达时间和乔达-转换jar文件是不是在我的libs目录。

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

注:似乎有不为任何需要显式导出的jar

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

推荐答案

您需要将乔达-convert.jar添加到您的libs文件夹。从 http://sourceforge.net/projects/joda-convert/下载JAR文件/乔达-转换/

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/