Adding external jar in adt 20 in android application projects

时间秒杀一切 提交于 2019-12-08 09:33:02

问题


07-06 10:32:07.244: E/dalvikvm(319): Could not find class 'org.AstroVed.Panchanga.Moment', referenced from method com.astroved.horawatch.HoraWatchActivity.onCreate
07-06 10:32:07.244: W/dalvikvm(319): VFY: unable to resolve new-instance 186 (Lorg/AstroVed/Panchanga/Moment;) in Lcom/astroved/horawatch/HoraWatchActivity;
07-06 10:32:07.254: D/dalvikvm(319): VFY: replacing opcode 0x22 at 0x000f
07-06 10:32:07.254: D/dalvikvm(319): VFY: dead code 0x0011-00f6 in Lcom/astroved/horawatch/HoraWatchActivity;.onCreate (Landroid/os/Bundle;)V
07-06 10:32:08.224: D/dalvikvm(319): GC_CONCURRENT freed 692K, 49% free 3439K/6727K, external 2022K/2137K, paused 4ms+4ms
07-06 10:32:08.953: D/AndroidRuntime(319): Shutting down VM
07-06 10:32:08.953: W/dalvikvm(319): threadid=1: thread exiting with uncaught exception (group=0x40015560)
07-06 10:32:08.963: E/AndroidRuntime(319): FATAL EXCEPTION: main
07-06 10:32:08.963: E/AndroidRuntime(319): java.lang.NoClassDefFoundError: org.AstroVed.Panchanga.Moment
07-06 10:32:08.963: E/AndroidRuntime(319):  at com.astroved.horawatch.HoraWatchActivity.onCreate(HoraWatchActivity.java:71)
07-06 10:32:08.963: E/AndroidRuntime(319):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-06 10:32:08.963: E/AndroidRuntime(319):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
07-06 10:32:08.963: E/AndroidRuntime(319):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
07-06 10:32:08.963: E/AndroidRuntime(319):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
07-06 10:32:08.963: E/AndroidRuntime(319):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
07-06 10:32:08.963: E/AndroidRuntime(319):  at android.os.Handler.dispatchMessage(Handler.java:99)
07-06 10:32:08.963: E/AndroidRuntime(319):  at android.os.Looper.loop(Looper.java:123)
07-06 10:32:08.963: E/AndroidRuntime(319):  at android.app.ActivityThread.main(ActivityThread.java:3683)
07-06 10:32:08.963: E/AndroidRuntime(319):  at java.lang.reflect.Method.invokeNative(Native Method)
07-06 10:32:08.963: E/AndroidRuntime(319):  at java.lang.reflect.Method.invoke(Method.java:507)
07-06 10:32:08.963: E/AndroidRuntime(319):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
07-06 10:32:08.963: E/AndroidRuntime(319):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
07-06 10:32:08.963: E/AndroidRuntime(319):  at dalvik.system.NativeStart.main(Native Method)

This is the error Iam getting in my apps in adt 20.....if i am using external jar.


回答1:


There are only a few reasons you will ever get this error:

  1. The class genuinely doesn't exist. If you are using code from an official example and getting this, make sure you have the latest build of the library
  2. You have not added the jar to your build path. To fix this, right click on the jar in Eclipse, and do Build Path ► Add to Build Path.
  3. Your jar is not in the /libs folder. This happens when you have added the jar to the build path, but newer versions of ADT need it to be in /libs. Put it there and re-add it to the build path.
  4. Your JAR file must be build compatible for Android (actual Java 7 compiled classes are not supported!).



回答2:


Remember always put all external jars in your apps libs. create libs folder where AndroidManifest.xml exists. Then refresh your project in eclipse. Then do as follows:

  1. Right click on your project in Eclipse
  2. click on properties.
  3. on properties window click on JavaBuildPath
  4. select Libraries tab
  5. click AddJARs button & add the external jars from your project's lib



回答3:


See this thread. They seem to be describing a problem very similar to yours. Maybe you lack some permission in your manifest for the activity you are trying to start?



来源:https://stackoverflow.com/questions/11356232/adding-external-jar-in-adt-20-in-android-application-projects

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