我刚刚开始Android游戏开发,我遇到了一个愚蠢的问题.我想在我的手机或虚拟机上运行一个应用程序,我收到此错误:
01-11 21:16:45.362: E/AndroidRuntime(19063): FATAL EXCEPTION: main 01-11 21:16:45.362: E/AndroidRuntime(19063): Process: com.mygdx.game, PID: 19063 01-11 21:16:45.362: E/AndroidRuntime(19063): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.mygdx.game/com.mygdx.game.AndroidLauncher}: java.lang.ClassNotFoundException: Didn't find class "com.mygdx.game.AndroidLauncher" on path: DexPathList[[zip file "/data/app/com.mygdx.game-1/base.apk"],nativeLibraryDirectories=[/data/app/com.mygdx.game-1/lib/arm, /vendor/lib, /system/lib]] 01-11 21:16:45.362: E/AndroidRuntime(19063): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2515) 01-11 21:16:45.362: E/AndroidRuntime(19063): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2723) 01-11 21:16:45.362: E/AndroidRuntime(19063): at android.app.ActivityThread.access$900(ActivityThread.java:172) 01-11 21:16:45.362: E/AndroidRuntime(19063): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1422) 01-11 21:16:45.362: E/AndroidRuntime(19063): at android.os.Handler.dispatchMessage(Handler.java:102) 01-11 21:16:45.362: E/AndroidRuntime(19063): at android.os.Looper.loop(Looper.java:145) 01-11 21:16:45.362: E/AndroidRuntime(19063): at android.app.ActivityThread.main(ActivityThread.java:5832) 01-11 21:16:45.362: E/AndroidRuntime(19063): at java.lang.reflect.Method.invoke(Native Method) 01-11 21:16:45.362: E/AndroidRuntime(19063): at java.lang.reflect.Method.invoke(Method.java:372) 01-11 21:16:45.362: E/AndroidRuntime(19063): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399) 01-11 21:16:45.362: E/AndroidRuntime(19063): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194) 01-11 21:16:45.362: E/AndroidRuntime(19063): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.mygdx.game.AndroidLauncher" on path: DexPathList[[zip file "/data/app/com.mygdx.game-1/base.apk"],nativeLibraryDirectories=[/data/app/com.mygdx.game-1/lib/arm, /vendor/lib, /system/lib]] 01-11 21:16:45.362: E/AndroidRuntime(19063): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) 01-11 21:16:45.362: E/AndroidRuntime(19063): at java.lang.ClassLoader.loadClass(ClassLoader.java:511) 01-11 21:16:45.362: E/AndroidRuntime(19063): at java.lang.ClassLoader.loadClass(ClassLoader.java:469) 01-11 21:16:45.362: E/AndroidRuntime(19063): at android.app.Instrumentation.newActivity(Instrumentation.java:1079) 01-11 21:16:45.362: E/AndroidRuntime(19063): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2505) 01-11 21:16:45.362: E/AndroidRuntime(19063): ... 10 more 01-11 21:16:45.362: E/AndroidRuntime(19063): Suppressed: java.lang.NoClassDefFoundError: com.mygdx.game.AndroidLauncher 01-11 21:16:45.362: E/AndroidRuntime(19063): at dalvik.system.DexFile.defineClassNative(Native Method) 01-11 21:16:45.362: E/AndroidRuntime(19063): at dalvik.system.DexFile.defineClass(DexFile.java:226) 01-11 21:16:45.362: E/AndroidRuntime(19063): at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:219) 01-11 21:16:45.362: E/AndroidRuntime(19063): at dalvik.system.DexPathList.findClass(DexPathList.java:321) 01-11 21:16:45.362: E/AndroidRuntime(19063): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54) 01-11 21:16:45.362: E/AndroidRuntime(19063): ... 14 more 01-11 21:16:45.362: E/AndroidRuntime(19063): Suppressed: java.lang.ClassNotFoundException: com.mygdx.game.AndroidLauncher 01-11 21:16:45.362: E/AndroidRuntime(19063): at java.lang.Class.classForName(Native Method) 01-11 21:16:45.362: E/AndroidRuntime(19063): at java.lang.BootClassLoader.findClass(ClassLoader.java:781) 01-11 21:16:45.362: E/AndroidRuntime(19063): at java.lang.BootClassLoader.loadClass(ClassLoader.java:841) 01-11 21:16:45.362: E/AndroidRuntime(19063): at java.lang.ClassLoader.loadClass(ClassLoader.java:504) 01-11 21:16:45.362: E/AndroidRuntime(19063): ... 13 more 01-11 21:16:45.362: E/AndroidRuntime(19063): Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
如果您有经验,请帮助我.祝你今天愉快.
右键单击android项目,然后单击属性 - > Java Build Path - > Order and Export,并勾选所有框.
清理项目并重建.
从eclipse中的不同android API切换时出现错误.
通常这种情况发生在一个新的libGDX项目上,当你没有默认的Android SDK(我的是19,我没有)时,它由Project - > properties - > Android修复,并选择构建目标.
进行这些更改后,始终清理项目.
上面两个问题是我总是遇到的libGDX和Eclipse,无论是在导入项目时,只是设置一个新的或者我重新安装Android SDK的时候.
希望这可以帮助.;-)