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

Raghav Sood
  • 81,899
  • 22
  • 187
  • 195
Kumar Shorav
  • 531
  • 4
  • 16
  • What you are showing is a stack trace. This means that you were able to run your application. So it is not a compilation error, but error during run time. If I read the error correctly you get it when you run some tests, don't you? – Boris Strandjev Jul 07 '12 at 06:45
  • Yes rightly you are saying...to remove this the Jar I am using ; pasted in the assets folder. Then this error gone but at the same time davlik conversion ffailed error 1 is coming before running????? Please suggest some soln???? – Kumar Shorav Jul 07 '12 at 06:47
  • I found some post in this site where it is mentioned that by putting jar in assets folder the jar would be available at runtime. – Kumar Shorav Jul 07 '12 at 06:48
  • My thought was somewhat different. Before that: can you please confirm that you actually have two projects: main project depending on this jar of yours and then test project for this main project? And you get the error when you run the test project? – Boris Strandjev Jul 07 '12 at 06:50
  • I am having one android project only. Now I am using one external jar that is causing this problems. – Kumar Shorav Jul 07 '12 at 06:54
  • Possible duplicate of [How can I use external JARs in an Android project?](http://stackoverflow.com/questions/1334802/how-can-i-use-external-jars-in-an-android-project) – Yochai Timmer Oct 31 '15 at 07:49

3 Answers3

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!).
derekerdmann
  • 17,696
  • 11
  • 76
  • 110
Raghav Sood
  • 81,899
  • 22
  • 187
  • 195
  • The Class exists because this jar is already running in my Java application. I have added the Jar because it is automatically coming up in Android dependencies. Moreover I did as you mentioned. I have placed the Jar in Libs Folder by copying manually and pasting it in the libs folder going via eclipse workspace. Please help if you can understand the errors. – Kumar Shorav Jul 06 '12 at 05:28
  • After adding it to /libs, did you remove it and re add it to the build path? Also, try doing a clean build via Project ► Clean and installing and running it again. – Raghav Sood Jul 06 '12 at 05:30
  • Yes, i removed it then the refrenced libraies are not visible. After that I clean the project and then started to run it. Then the error is coming too... – Kumar Shorav Jul 06 '12 at 05:34
  • Did you re add it after removing it? Are you sure you got the spelling of the class right? Java is case sensitive. – Raghav Sood Jul 06 '12 at 05:35
  • Yes. The build path. Make sure you add the one in /libs, and not from somewhere else. – Raghav Sood Jul 06 '12 at 05:38
  • Yes I add it through Libs now and then clean the project after that I rebuild and run ...same error :( – Kumar Shorav Jul 06 '12 at 05:40
  • I got nothing then. These three should have fixed that error. – Raghav Sood Jul 06 '12 at 05:44
  • This jar is built by me and well running in Java Application by using external jar through build path. However in Android App, this problems are coming.....repeatedly I am using the above suggested method ....but without success.... :( – Kumar Shorav Jul 06 '12 at 05:48
  • Is your jar android compatible? Does it use Java classes not available in the Android framework? – Raghav Sood Jul 06 '12 at 05:49
  • I just created the Jar using Java 1.7.... using general clases...BTW ....how to check compatiablity.. of android.??? While importing the error class as for ex (Moment) is available in the jar because while importing it is showing in the pkg. – Kumar Shorav Jul 06 '12 at 06:16
  • JDK 7 isn't supported by Android fully. TO check the compatibility, simply go to the project properties and add Android to it from the Android tab. If anything is incompatible, you'll get an error. – Raghav Sood Jul 06 '12 at 06:20
  • yes it may cause this... JDK 7 isn't supported by Android fully. so try to rebuild your jar that should support android. – Soumyadip Das Jul 06 '12 at 07:01
  • nothing working ....i am just struggling with this............... However the problem is at runtime not at compile time because When I am importing the same class ... it is visible and I am able to intialize the constructor for the same class without error...but at run time it is showing following error-- 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): Is it error related to class path?????? – Kumar Shorav Jul 06 '12 at 10:23
1

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
Soumyadip Das
  • 1,781
  • 3
  • 16
  • 34
  • Hi.... I tried the same 1. AndroidManifest.xml exists 2. Refgreshed 3. Already Libs folder is there and so I added the Jar file. and then did "Add Build path" 4. Selected Libraries tab 5. Added the external jar from the libs folder from Project libs. Do you mean there are some lib folder in Project/ Libs folder are already there....???? :( – Kumar Shorav Jul 06 '12 at 06:11
  • it requires **libs** folder, not lib. Their are no libs folder by default in android project. you have to create it where AndroidManifest.xml exists. – Soumyadip Das Jul 06 '12 at 06:14
  • just create the folder in proper place. – Soumyadip Das Jul 06 '12 at 06:24
  • libs folder is in the same folder where AndroidManifest.xml are. Moreover thge spelling are "libs". should it be like "Libs"???? – Kumar Shorav Jul 06 '12 at 06:42
  • edit your question and append the errors in your question's lower side. – Soumyadip Das Jul 06 '12 at 06:46
  • but same error repetedly coming....???? 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; – Kumar Shorav Jul 06 '12 at 06:51
  • program unexpectedely shut down. – Kumar Shorav Jul 06 '12 at 06:54
  • i am not sure about the solution, because if you correctly performs all the steps to add external jar... yet the problem exists, then probably that's not a problem with the jar. probably the problem is something else. expecting experienced peoples helps... – Soumyadip Das Jul 06 '12 at 06:59
  • nothing working ....i am just struggling with this............... However the problem is at runtime not at compile time because When I am importing the same class ... it is visible and I am able to intialize the constructor for the same class without error...but at run time it is showing following error-- 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): Is it error related to class path?????? – Kumar Shorav Jul 06 '12 at 10:17
1

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?

Community
  • 1
  • 1
Boris Strandjev
  • 46,145
  • 15
  • 108
  • 135