我正在使用LibGDX构建游戏,之前我已经能够启动桌面和Android项目,但是我最近集成了一个额外的外部库,现在Android项目无法启动(但是桌面项目仍然启动而没有错误。)
LogCat输出为:
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)
据我所知,我正确地导入了库,因为它出现在我项目的Referenced Libraries文件夹中,但也许我错过了什么?
在有帮助的情况下使用Eclipse。
答案 0 :(得分:1)
这位博主声称拥有更新的教程(Eclipse):http://www.piotrjastrzebski.io/blog/libgdx-gradle-tutorial
以下是与其他人讨论您所遇到的错误消息的论坛:http://badlogicgames.com/forum/viewtopic.php?f=11&t=13710
一般情况下,如果您在论坛上发帖而不是StackOverflow,您可能会获得更多相关建议。 (虽然没有理由不向两者发帖)
http://badlogicgames.com/forum/viewforum.php?f=11&sid=3cbebdbdd7e8df970c6bd1cbfc84de37
例如,我是一名Android开发人员,我可以想到在导入库项目时可能会出错的一些事情,但似乎这个lib有一个安装库(gdx-setup.jar)对你不利的东西,我无法提供建议。
答案 1 :(得分:0)
原来问题出在构建路径配置中。这些库已添加到构建路径中,并列在构建路径对话框的“库”选项卡中,但是在“订购和导出”选项卡中未检查库。
我检查了它们,现在它可以工作了。