我对编程很陌生,我正在努力解决下一个问题。我正在使用LibGDX创建一个基于Tiled的游戏(以下教程)。现在桌面部分一切正常,并且应该像它一样工作。但是,当我尝试运行android部分时,它会立即崩溃。在我的logcat下面和代码。需要更多信息请告诉我。欢迎任何帮助。
02-15 20:59:16.135 356-356/com.sparetimegaming.game.android W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x40015560)
02-15 20:59:16.225 356-356/com.sparetimegaming.game.android E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.sparetimegaming.game.android/com.sparetimegaming.game.android.AndroidLauncher}: com.badlogic.gdx.utils.GdxRuntimeException: Libgdx requires OpenGL ES 2.0
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Libgdx requires OpenGL ES 2.0
at com.badlogic.gdx.backends.android.AndroidGraphics.createGLSurfaceView(AndroidGraphics.java:127)
at com.badlogic.gdx.backends.android.AndroidGraphics.<init>(AndroidGraphics.java:107)
at com.badlogic.gdx.backends.android.AndroidGraphics.<init>(AndroidGraphics.java:100)
at com.badlogic.gdx.backends.android.AndroidApplication.init(AndroidApplication.java:133)
at com.badlogic.gdx.backends.android.AndroidApplication.initialize(AndroidApplication.java:99)
at com.sparetimegaming.game.android.AndroidLauncher.onCreate(AndroidLauncher.java:15)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
02-15 20:59:18.825 356-356/com.sparetimegaming.game.android I/Process﹕ Sending signal. PID: 356 SIG: 9
在我的发射器下面:
package com.sparetimegaming.game.desktop;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import com.sparetimegaming.game.TiledMapGame;
public class DesktopLauncher {
public static void main (String[] arg) {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
config.title = "TiledMapGame";
config.width = 1280;
config.height = 720;
config.useGL30 = true;
new LwjglApplication(new TiledMapGame(), config);
}
}
package com.sparetimegaming.game.android;
import android.os.Bundle;
import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
import com.sparetimegaming.game.TiledMapGame;
public class AndroidLauncher extends AndroidApplication {
@Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
initialize(new TiledMapGame(), config);
}
}
答案 0 :(得分:1)
如果您使用的是模拟器,那么模拟器可能就是问题所在。
正如你在这里看到的那样:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.sparetimegaming.game.android/com.sparetimegaming.game.android.AndroidLauncher}: com.badlogic.gdx.utils.GdxRuntimeException: Libgdx requires OpenGL ES 2.0
它说Libgdx需要Open GL 2.0。处理模拟器时,这是一个常见错误。尝试使用旧版本的模拟器(低于API 19)并查看它是否可行。如果你有一个Android手机,你也可以尝试在那里运行它。 (我假设你使用的是模拟器)。