找不到LibGDX类

时间:2013-03-05 02:39:52

标签: android libgdx dex

我的程序崩溃了

03-05 02:21:57.127: E/dalvikvm(12583): Could not find class 'com.deerandcatgames.spikeJumper.GUI.OuyaTable$1', referenced from method com.deerandcatgames.spikeJumper.GUI.OuyaTable.<init>

每当我在android上运行它时,从桌面项目运行它就可以了。

我看一下logcat,发现以下错误:

03-05 02:21:56.907: I/SpikeJumper(12583): Showing screen: SplashScreen
03-05 02:21:56.957: D/dalvikvm(12583): GC_FOR_ALLOC freed 23K, 5% free 7525K/7920K, paused 37ms, total 37ms
03-05 02:21:57.127: W/dalvikvm(12583): Unable to resolve superclass of Lcom/deerandcatgames/spikeJumper/GUI/OuyaTable$1; (347)
03-05 02:21:57.127: W/dalvikvm(12583): Link of class 'Lcom/deerandcatgames/spikeJumper/GUI/OuyaTable$1;' failed
03-05 02:21:57.127: E/dalvikvm(12583): Could not find class 'com.deerandcatgames.spikeJumper.GUI.OuyaTable$1', referenced from method com.deerandcatgames.spikeJumper.GUI.OuyaTable.<init>
03-05 02:21:57.127: W/dalvikvm(12583): VFY: unable to resolve new-instance 992 (Lcom/deerandcatgames/spikeJumper/GUI/OuyaTable$1;) in Lcom/deerandcatgames/spikeJumper/GUI/OuyaTable;
03-05 02:21:57.127: D/dalvikvm(12583): VFY: replacing opcode 0x22 at 0x0016
03-05 02:21:57.127: I/dalvikvm(12583): Could not find method com.badlogic.gdx.controllers.Controllers.removeListener, referenced from method com.deerandcatgames.spikeJumper.GUI.OuyaTable.dispose
03-05 02:21:57.127: W/dalvikvm(12583): VFY: unable to resolve static method 2760: Lcom/badlogic/gdx/controllers/Controllers;.removeListener (Lcom/badlogic/gdx/controllers/ControllerListener;)V
03-05 02:21:57.127: D/dalvikvm(12583): VFY: replacing opcode 0x71 at 0x0007
03-05 02:21:57.127: W/dalvikvm(12583): Unable to resolve superclass of Lcom/deerandcatgames/spikeJumper/GUI/OuyaTable$1; (347)
03-05 02:21:57.127: W/dalvikvm(12583): Link of class 'Lcom/deerandcatgames/spikeJumper/GUI/OuyaTable$1;' failed
03-05 02:21:57.137: D/dalvikvm(12583): DexOpt: unable to opt direct call 0x26b5 at 0x18 in Lcom/deerandcatgames/spikeJumper/GUI/OuyaTable;.<init>
03-05 02:21:57.187: D/dalvikvm(12583): GC_CONCURRENT freed 399K, 8% free 7578K/8236K, paused 3ms+5ms, total 29ms
03-05 02:21:57.257: I/SpikeJumper(12583): Setting up custom table
03-05 02:21:57.257: W/dalvikvm(12583): threadid=11: thread exiting with uncaught exception (group=0x418a3930)
03-05 02:21:57.257: E/AndroidRuntime(12583): FATAL EXCEPTION: GLThread 19356
03-05 02:21:57.257: E/AndroidRuntime(12583): java.lang.NoClassDefFoundError: com.deerandcatgames.spikeJumper.GUI.OuyaTable$1
03-05 02:21:57.257: E/AndroidRuntime(12583):    at com.deerandcatgames.spikeJumper.GUI.OuyaTable.<init>(OuyaTable.java:72)
03-05 02:21:57.257: E/AndroidRuntime(12583):    at com.deerandcatgames.spikeJumper.screens.AbstractScreen.getTable(AbstractScreen.java:84)
03-05 02:21:57.257: E/AndroidRuntime(12583):    at com.deerandcatgames.spikeJumper.screens.AbstractScreen.resize(AbstractScreen.java:52)
03-05 02:21:57.257: E/AndroidRuntime(12583):    at com.deerandcatgames.spikeJumper.screens.SplashScreen.resize(SplashScreen.java:49)
03-05 02:21:57.257: E/AndroidRuntime(12583):    at com.badlogic.gdx.Game.setScreen(Game.java:63)
03-05 02:21:57.257: E/AndroidRuntime(12583):    at com.deerandcatgames.spikeJumper.SpikeJumper.setScreen(SpikeJumper.java:61)
03-05 02:21:57.257: E/AndroidRuntime(12583):    at com.deerandcatgames.spikeJumper.SpikeJumper.resize(SpikeJumper.java:79)
03-05 02:21:57.257: E/AndroidRuntime(12583):    at com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:334)
03-05 02:21:57.257: E/AndroidRuntime(12583):    at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1505)
03-05 02:21:57.257: E/AndroidRuntime(12583):    at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)

OuyaTable是

public class OuyaTable extends Table {
....
}

我已经尝试了所有我能想到的东西,它仍然无法在Android上运行。有没有人见过这个,和/或知道如何修复它?

3 个答案:

答案 0 :(得分:1)

好的,再试一次,但要多注意错误信息......我明白了:

Could not find method com.badlogic.gdx.controllers.Controllers.removeListener, referenced from method com.deerandcatgames.spikeJumper.GUI.OuyaTable.dispose

链接失败的原因之一。我认为你必须使用libgdx“controllers”扩展...你需要添加gdx-controllers-android.jar。请参阅badlogic博客的“集成到您的项目”部分:http://www.badlogicgames.com/wordpress/?p=2724

答案 1 :(得分:0)

gdx.jar(包含与平台无关的Libgdx类)可能没有打包到您的Android .APK中。 (与特定于Android的Libgdx类相比,这些类包含在gdx-backend-android.jar中,并且确实可以将其转换为您的.APK。)

您需要确保您的Android项目正在导出gdx.jar。在 Project Explorer 中右键单击您的Android项目,选择 Properties ,选择 Java Build Path ,然后选择 Order and Export < / em>标签。确保gdx.jargdx-backend-android.jar都已“选中”(以及您的常用项目)。

答案 2 :(得分:-1)

java = caca,adt = caca,eclipse = ..... 我遇到了这个问题,解决了在疯狂几个小时之后将主要项目(教程中的星际攻击)从java 1.7更改为java 1.6 ...