English 中文(简体)
Anders java.lang.NoClassDefFoundError using JODA Library
原标题:Android java.lang.NoClassDefFoundError using JODA libraries

I m stuck from about 2 hours on a problem that i thought it was easy to solve. I m building a custom date-time picker for the android platform and, because of the slowness of the standard java.util.Calendar and java.util.Date classes, i decided to use the JODA library.

Unfortunately i ve got no experience with JAR references (forgive me...i come from COM and .NET assemblies world =)...), but i learn some tips on internet but obviously they seems to be wrong... These are the steps i took to use the library in my project:

  1. Download the latest JODA library 2.1
  2. Create the lib folder into my project folder
  3. Add joda-time-2.1.jar to the lib folder.
  4. Add the joda-time-2.1.jar library to the build path.
  5. Add joda-time-2.1-javadoc.jar and joda-time-2.1-sources.jar to the lib folder
  6. Set the above libraries as java source attachements and javadoc location for the joda-time-2.1 referenced library.
  7. Use the new library into my code (the ehm ehm intelli-sense and compiler don t throws any error or warning)
  8. Start debug on real or virtual device.

当涉及以下线时(第一个使用JODA BTW的线),便停止:

DateTime newDate = new DateTime(2012, 5, 3, 12, 0, 0);

并归还以下痕迹:

05-03 19:09:14.349: E/AndroidRuntime(4071): java.lang.NoClassDefFoundError: org.joda.time.DateTime
05-03 19:09:14.349: E/AndroidRuntime(4071):     at it.paganel.droidMessageExport.Control.TimePickerControl.SetTimePart(TimePickerControl.java:83)
05-03 19:09:14.349: E/AndroidRuntime(4071):     at it.paganel.droidMessageExport.Control.TimePickerControl.onClick(TimePickerControl.java:116)
05-03 19:09:14.349: E/AndroidRuntime(4071):     at android.view.View.performClick(View.java:2454)
05-03 19:09:14.349: E/AndroidRuntime(4071):     at android.view.View$PerformClick.run(View.java:9030)
05-03 19:09:14.349: E/AndroidRuntime(4071):     at android.os.Handler.handleCallback(Handler.java:587)
05-03 19:09:14.349: E/AndroidRuntime(4071):     at android.os.Handler.dispatchMessage(Handler.java:92)
05-03 19:09:14.349: E/AndroidRuntime(4071):     at android.os.Looper.loop(Looper.java:123)
05-03 19:09:14.349: E/AndroidRuntime(4071):     at android.app.ActivityThread.main(ActivityThread.java:4641)
05-03 19:09:14.349: E/AndroidRuntime(4071):     at java.lang.reflect.Method.invokeNative(Native Method)
05-03 19:09:14.349: E/AndroidRuntime(4071):     at java.lang.reflect.Method.invoke(Method.java:521)
05-03 19:09:14.349: E/AndroidRuntime(4071):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:870)
05-03 19:09:14.349: E/AndroidRuntime(4071):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:628)
05-03 19:09:14.349: E/AndroidRuntime(4071):     at dalvik.system.NativeStart.main(Native Method)
05-03 19:09:14.349: E/AndroidRuntime(4071): Caused by: java.lang.ClassNotFoundException: org.joda.time.DateTime in loader dalvik.system.PathClassLoader[/data/app/it.paganel.droidMessageExport-2.apk]
05-03 19:09:14.349: E/AndroidRuntime(4071):     at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
05-03 19:09:14.349: E/AndroidRuntime(4071):     at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
05-03 19:09:14.349: E/AndroidRuntime(4071):     at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
05-03 19:09:14.349: E/AndroidRuntime(4071):     ... 13 more

Someone can help me? Thanks in advance!

最佳回答

Rename the lib folder to libs. As of ADT Tools 17 externals jars get only packaged into the apk if they are inside this folder. Alternatively you could go to "configure build path.."->"Order and Export" and click the checkbox next to the jar.

问题回答

对于可能寻求解决办法的其他人,我刚刚发现另一个可能的原因: 开放式项目和项目;Properties>Java Building Path>Libraries;如果Jodatime在Android DependenciesAndroid Private Libraries. 然后,确保相应的选择在Order and Export tab上检查。 我必须检查Android Private Libraries(如果把Jodatime列入名单),以便使其发挥作用。

我认为,这也适用于类似问题,不一定与Jodatime有关。





相关问题
Mysql compaire two dates from datetime?

I was try to measure what is faster and what should be the best way to compare two dates, from datetime record in MySql db. There are several approaches how to grab a date from date time, but I was ...

iPhone Date Picker rolls over to 2010 on December 27th?

So I implemented a UIDatepicker in one of my applications for scheduling and autodialing teleconferences... everything is pretty much ready to go except, while testing I noticed that when the date ...

Convert date Python

I have MMDDYY dates, i.e. today is 111609 How do I convert this to 11/16/2009, in Python?

specifying date format when using $form->inputs() in CakePHP

I am wondering if there is a way to specify the date format in the forms created using CakePHP s $form->inputs(); Please note that this is not the individual $form->input() but instead $form->inputs() ...

NSDateFormat, super simple! Where am I screwing up?

Ok, this is really simple, maybe I m a getting a bit burnt out, but seems like it should work, Query XML feed, put out date string, format, display in a cell. The issue is I m a getting a NULL ...

sqlite writing a date into an email

I am exporting a date value from sqlite and placing it into an email. The date appears like this 279498721.322872 I am using Objective C in an Iphone App. Does anyone know how to make this export ...

热门标签