java.lang.NoClassDefFoundError & Failed resolving ... interface 804 (LibGDX)

380 views Asked by At

I'm building a game using LibGDX and previously I've been able to launch both the Desktop and Android projects, however I recently integrated an additional external library and now the Android project is failing to launch (however the Desktop project still launches with no errors).

The LogCat output is:

06-19 13:34:04.011: E/Trace(16405): error opening trace file: No such file or directory (2)
06-19 13:34:04.777: D/dalvikvm(16405): Trying to load lib /data/data/com.kittykazoo.distantshores.android/lib/libgdx.so 0x41703278
06-19 13:34:05.011: D/dalvikvm(16405): Added shared lib /data/data/com.kittykazoo.distantshores.android/lib/libgdx.so 0x41703278
06-19 13:34:05.011: D/dalvikvm(16405): No JNI_OnLoad found in /data/data/com.kittykazoo.distantshores.android/lib/libgdx.so 0x41703278, skipping init
06-19 13:34:05.230: I/dalvikvm(16405): Failed resolving Lcom/kittykazoo/distantshores/DistantShores$1; interface 804 'Lcom/badlogic/gdx/pay/PurchaseObserver;'
06-19 13:34:05.230: W/dalvikvm(16405): Link of class 'Lcom/kittykazoo/distantshores/DistantShores$1;' failed
06-19 13:34:05.238: E/dalvikvm(16405): Could not find class 'com.kittykazoo.distantshores.DistantShores$1', referenced from method com.kittykazoo.distantshores.DistantShores.<init>
06-19 13:34:05.238: W/dalvikvm(16405): VFY: unable to resolve new-instance 1258 (Lcom/kittykazoo/distantshores/DistantShores$1;) in Lcom/kittykazoo/distantshores/DistantShores;
06-19 13:34:05.238: D/dalvikvm(16405): VFY: replacing opcode 0x22 at 0x0003
06-19 13:34:05.238: I/dalvikvm(16405): Failed resolving Lcom/kittykazoo/distantshores/DistantShores$1; interface 804 'Lcom/badlogic/gdx/pay/PurchaseObserver;'
06-19 13:34:05.238: W/dalvikvm(16405): Link of class 'Lcom/kittykazoo/distantshores/DistantShores$1;' failed
06-19 13:34:05.238: D/dalvikvm(16405): DexOpt: unable to opt direct call 0x3668 at 0x05 in Lcom/kittykazoo/distantshores/DistantShores;.<init>
06-19 13:34:05.238: D/dalvikvm(16405): DexOpt: unable to opt direct call 0x2017 at 0x0c in Lcom/kittykazoo/distantshores/DistantShores;.<init>
06-19 13:34:05.246: D/dalvikvm(16405): DexOpt: unable to opt direct call 0x2013 at 0x15 in Lcom/kittykazoo/distantshores/DistantShores;.<init>
06-19 13:34:05.246: I/dalvikvm(16405): DexOpt: unable to optimize static field ref 0x10d8 at 0x18 in Lcom/kittykazoo/distantshores/DistantShores;.<init>
06-19 13:34:05.324: D/AndroidRuntime(16405): Shutting down VM
06-19 13:34:05.324: W/dalvikvm(16405): threadid=1: thread exiting with uncaught exception (group=0x40f032a0)
06-19 13:34:05.597: E/AndroidRuntime(16405): FATAL EXCEPTION: main
06-19 13:34:05.597: E/AndroidRuntime(16405): java.lang.NoClassDefFoundError: com.kittykazoo.distantshores.DistantShores$1
06-19 13:34:05.597: E/AndroidRuntime(16405):    at com.kittykazoo.distantshores.DistantShores.<init>(DistantShores.java:43)
06-19 13:34:05.597: E/AndroidRuntime(16405):    at com.kittykazoo.distantshores.android.AndroidLauncher.onCreate(AndroidLauncher.java:18)
06-19 13:34:05.597: E/AndroidRuntime(16405):    at android.app.Activity.performCreate(Activity.java:5058)
06-19 13:34:05.597: E/AndroidRuntime(16405):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
06-19 13:34:05.597: E/AndroidRuntime(16405):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
06-19 13:34:05.597: E/AndroidRuntime(16405):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2174)
06-19 13:34:05.597: E/AndroidRuntime(16405):    at android.app.ActivityThread.access$700(ActivityThread.java:141)
06-19 13:34:05.597: E/AndroidRuntime(16405):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1267)
06-19 13:34:05.597: E/AndroidRuntime(16405):    at android.os.Handler.dispatchMessage(Handler.java:99)
06-19 13:34:05.597: E/AndroidRuntime(16405):    at android.os.Looper.loop(Looper.java:137)
06-19 13:34:05.597: E/AndroidRuntime(16405):    at android.app.ActivityThread.main(ActivityThread.java:5059)
06-19 13:34:05.597: E/AndroidRuntime(16405):    at java.lang.reflect.Method.invokeNative(Native Method)
06-19 13:34:05.597: E/AndroidRuntime(16405):    at java.lang.reflect.Method.invoke(Method.java:511)
06-19 13:34:05.597: E/AndroidRuntime(16405):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
06-19 13:34:05.597: E/AndroidRuntime(16405):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
06-19 13:34:05.597: E/AndroidRuntime(16405):    at dalvik.system.NativeStart.main(Native Method)

As far as I know I imported the library properly, as it's showing up in my project's Referenced Libraries folder, but maybe I missed something?

Using Eclipse in case that helps.

2

There are 2 answers

1
sitting-duck On

This blogger claims to have a more up to date tutorial (Eclipse): http://www.piotrjastrzebski.io/blog/libgdx-gradle-tutorial

Here is a forum with other people discussing the same error message you have: http://badlogicgames.com/forum/viewtopic.php?f=11&t=13710

In general you might get more relevant advice if you post on their forum instead of StackOverflow. (although no reason not to post to both)

http://badlogicgames.com/forum/viewforum.php?f=11&sid=3cbebdbdd7e8df970c6bd1cbfc84de37

For example, I am an Android developer, and I can think of a few things that might typically go wrong when importing a library project, but it seems like this lib has a setup library (gdx-setup.jar) that does stuff for you that is outside of my control and I cannot advise on.

0
1337ingDisorder On

Turned out the problem was in the Build Path configuration. The libraries had been added to the build path and were listed in the Libraries tab of the build path dialog, however in the Order and Export tab the libraries weren't checked.

I checked them and now it works.