I am a bit new to Android development so bear with me.
I've already reviewed this MapView: Could not find class A referenced from method B and this Could not find method XXX, referenced from method YYY
but they do not help solve my issue.
I am getting the error reported in my question title when trying to run my app. My app requires a java project that I pulled from Github, which itself required a handful of jar files to compile on its own. I have the java project compiled, and Eclipse makes my android project appear to be compiled, but it isn't working on my phone.
I tried the following, all leading to the same result:
- referenced the java library directly using the java build path
- built an android project library which references the java library directly using the java build path, then adding the android project library to my projects android library path
- built an android project library which references a jar I built from the java library, then adding the android project library to my projects android library path
- built a jar from the java library, then adding the jar to the build path of my android project
the end result is always the same, my program compiles but when I try to run it crashes saying "could not find class "class from the GitHub project" referenced from "my main activity method"
Could anyone throw a bone?
Logcat
12-14 11:08:49.792: I/Process(5538): Sending signal. PID: 5538 SIG: 9
12-14 11:09:56.722: D/szipinf(5626): Initializing inflate state
12-14 11:09:56.732: E/dalvikvm(5626): Could not find class 'gmusic.api.impl.GoogleSkyJamAPI', referenced from method com.example.gpmx.MainActivity.runGoogleAPI
12-14 11:09:56.732: W/dalvikvm(5626): VFY: unable to resolve new-instance 445 (Lgmusic/api/impl/GoogleSkyJamAPI;) in Lcom/example/gpmx/MainActivity;
12-14 11:09:56.732: D/dalvikvm(5626): VFY: replacing opcode 0x22 at 0x0000
12-14 11:09:56.732: D/dalvikvm(5626): VFY: dead code 0x0002-0036 in Lcom/example/gpmx/MainActivity;.runGoogleAPI (Ljava/lang/String;Ljava/lang/String;)V
12-14 11:09:56.812: D/AndroidRuntime(5626): Shutting down VM
12-14 11:09:56.812: W/dalvikvm(5626): threadid=1: thread exiting with uncaught exception (group=0x40018560)
12-14 11:09:56.812: E/AndroidRuntime(5626): FATAL EXCEPTION: main
12-14 11:09:56.812: E/AndroidRuntime(5626): java.lang.NoClassDefFoundError: gmusic.api.impl.GoogleSkyJamAPI
12-14 11:09:56.812: E/AndroidRuntime(5626): at com.example.gpmx.MainActivity.runGoogleAPI(MainActivity.java:63)
12-14 11:09:56.812: E/AndroidRuntime(5626): at com.example.gpmx.MainActivity.onResume(MainActivity.java:36)
12-14 11:09:56.812: E/AndroidRuntime(5626): at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1150)
12-14 11:09:56.812: E/AndroidRuntime(5626): at android.app.Activity.performResume(Activity.java:3832)
12-14 11:09:56.812: E/AndroidRuntime(5626): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2231)
12-14 11:09:56.812: E/AndroidRuntime(5626): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2256)
12-14 11:09:56.812: E/AndroidRuntime(5626): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1789)
12-14 11:09:56.812: E/AndroidRuntime(5626): at android.app.ActivityThread.access$1500(ActivityThread.java:123)
12-14 11:09:56.812: E/AndroidRuntime(5626): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
12-14 11:09:56.812: E/AndroidRuntime(5626): at android.os.Handler.dispatchMessage(Handler.java:99)
12-14 11:09:56.812: E/AndroidRuntime(5626): at android.os.Looper.loop(Looper.java:130)
12-14 11:09:56.812: E/AndroidRuntime(5626): at android.app.ActivityThread.main(ActivityThread.java:3835)
12-14 11:09:56.812: E/AndroidRuntime(5626): at java.lang.reflect.Method.invokeNative(Native Method)
12-14 11:09:56.812: E/AndroidRuntime(5626): at java.lang.reflect.Method.invoke(Method.java:507)
12-14 11:09:56.812: E/AndroidRuntime(5626): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
12-14 11:09:56.812: E/AndroidRuntime(5626): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
12-14 11:09:56.812: E/AndroidRuntime(5626): at dalvik.system.NativeStart.main(Native Method)
One more piece of information, if this helps. The java project I am using depends on various apache and google jars, which are in the java projects "lib" (not "libs") folder. Is this a problem when creating a jar?
Final update: It turned out that there was a lesson learned. At least with my configuration, all of the jars I needed in the android library had to be at the same directory level, that is, just under "libs". I have a couple of required jars, like apaches common.io jar within it's own directory under "libs", this was causing a problem.