我刚刚开始在android中创建一个带libgdx的简单游戏。 我可以在此处找到我正在制作的应用程序:https://github.com/libgdx/libgdx/wiki/A-simple-game
所以我按照教程中的说法创建了所有内容,并成功将5个文件夹导入eclipse。后来我也创建了一个AVD,所以我可以运行我的应用程序。以下是设置:http://i.imgur.com/Cx0rjsB.png
注意:(即使我在导入5个文件夹后测试运行应用程序,它也无法正常工作,因为它应该至少显示libgdx图像和红色背景。)
当AVD打开时,它相当迟钝但仍能正常工作。所以我运行应用程序,我在logcat中得到了很多错误(请注意我是eclipse和android应用程序的初学者):
04-11 05:43:49.546: D/AndroidRuntime(1092): Shutting down VM
04-11 05:43:49.546: W/dalvikvm(1092): threadid=1: thread exiting with uncaught exception (group=0xb1b0cba8)
04-11 05:43:49.586: E/AndroidRuntime(1092): FATAL EXCEPTION: main
04-11 05:43:49.586: E/AndroidRuntime(1092): Process: com.badlogic.drop, PID: 1092
04-11 05:43:49.586: E/AndroidRuntime(1092): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.badlogic.drop/com.badlogic.drop.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.badlogic.drop.MainActivity" on path: DexPathList[[zip file "/data/app/com.badlogic.drop-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.badlogic.drop-1, /system/lib]]
04-11 05:43:49.586: E/AndroidRuntime(1092): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2121)
04-11 05:43:49.586: E/AndroidRuntime(1092): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
04-11 05:43:49.586: E/AndroidRuntime(1092): at android.app.ActivityThread.access$800(ActivityThread.java:135)
04-11 05:43:49.586: E/AndroidRuntime(1092): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
04-11 05:43:49.586: E/AndroidRuntime(1092): at android.os.Handler.dispatchMessage(Handler.java:102)
04-11 05:43:49.586: E/AndroidRuntime(1092): at android.os.Looper.loop(Looper.java:136)
04-11 05:43:49.586: E/AndroidRuntime(1092): at android.app.ActivityThread.main(ActivityThread.java:5017)
04-11 05:43:49.586: E/AndroidRuntime(1092): at java.lang.reflect.Method.invokeNative(Native Method)
04-11 05:43:49.586: E/AndroidRuntime(1092): at java.lang.reflect.Method.invoke(Method.java:515)
04-11 05:43:49.586: E/AndroidRuntime(1092): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
04-11 05:43:49.586: E/AndroidRuntime(1092): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
04-11 05:43:49.586: E/AndroidRuntime(1092): at dalvik.system.NativeStart.main(Native Method)
04-11 05:43:49.586: E/AndroidRuntime(1092): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.badlogic.drop.MainActivity" on path: DexPathList[[zip file "/data/app/com.badlogic.drop-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.badlogic.drop-1, /system/lib]]
04-11 05:43:49.586: E/AndroidRuntime(1092): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
04-11 05:43:49.586: E/AndroidRuntime(1092): at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
04-11 05:43:49.586: E/AndroidRuntime(1092): at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
04-11 05:43:49.586: E/AndroidRuntime(1092): at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
04-11 05:43:49.586: E/AndroidRuntime(1092): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
04-11 05:43:49.586: E/AndroidRuntime(1092): ... 11 more
04-11 05:44:04.046: I/Process(1092): Sending signal. PID: 1092 SIG: 9
如果有人知道如何解决方案或有任何其他问题,请告诉我。
答案 0 :(得分:0)
logcat中的错误表明崩溃是由于未找到类MainActivity引起的。 (“引起:java.lang.ClassNotFoundException:没有找到类”com.badlogic.drop.MainActivity“)
在您的清单中,您已指定启动器活动“.MainActivity”
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
请确保类MainActivity正确地出现在项目的正确包中:“com.badlogic.drop”。
答案 1 :(得分:0)
将此代码放入清单文件中:
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
你得到的课程没有找到异常检查一次&#34; com.badlogic.drop.MainActivity&#34;这个班级是否存在。如果可能发生任何字母字符更改。