Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
239 views
in Technique[技术] by (71.8m points)

java - LibGDX HelloWorld project crashes when run on Android emulator

I've been trying to get the Hello-World project to run as part of learning LibGDX. Using the Nightly Build (libgdx-nightly-20140322). However, I have become quite frustrated because the hello-world-desktop project will work when run as a Java Application, the hello-world-html project will Run As a Web Application. But hello-world-android simple produces a not very descriptive error:

image of LibGDX failure in Android emulator

I have checked on here looking for similar problems and found Android Emulator does not launch LibGDX project?, but the solution given does not work with what I have. There was also libgdx my first triangle tutorial not working?, which pointed me to new tutorials to try, but no avail.

The first time I attempted to follow the tutorial on GITHUB, and the second time Games from Scratch's LibGDX Tutorial 1: Creating an initial project. I have tried different API Levels 8, 13, 16, & 19.

Here is the dump of the logfile:

03-28 03:41:33.344: E/Trace(622): error opening trace file: No such file or directory (2)
03-28 03:41:33.435: D/dalvikvm(622): Trying to load lib /data/data/com.me.mygdxgame/lib/libgdx.so 0x411e9590
03-28 03:41:33.445: D/dalvikvm(622): Added shared lib /data/data/com.me.mygdxgame/lib/libgdx.so 0x411e9590
03-28 03:41:33.445: D/dalvikvm(622): No JNI_OnLoad found in /data/data/com.me.mygdxgame/lib/libgdx.so 0x411e9590, skipping init
03-28 03:41:33.465: D/libEGL(622): Emulator without GPU support detected. Fallback to software renderer.
03-28 03:41:33.496: D/libEGL(622): loaded /system/lib/egl/libGLES_android.so
03-28 03:41:33.535: D/AndroidRuntime(622): Shutting down VM
03-28 03:41:33.535: W/dalvikvm(622): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
03-28 03:41:33.555: E/AndroidRuntime(622): FATAL EXCEPTION: main
03-28 03:41:33.555: E/AndroidRuntime(622): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.me.mygdxgame/com.me.mygdxgame.MainActivity}: java.lang.RuntimeException: Libgdx requires OpenGL ES 2.0
03-28 03:41:33.555: E/AndroidRuntime(622):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
03-28 03:41:33.555: E/AndroidRuntime(622):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
03-28 03:41:33.555: E/AndroidRuntime(622):  at android.app.ActivityThread.access$600(ActivityThread.java:130)
03-28 03:41:33.555: E/AndroidRuntime(622):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
03-28 03:41:33.555: E/AndroidRuntime(622):  at android.os.Handler.dispatchMessage(Handler.java:99)
03-28 03:41:33.555: E/AndroidRuntime(622):  at android.os.Looper.loop(Looper.java:137)
03-28 03:41:33.555: E/AndroidRuntime(622):  at android.app.ActivityThread.main(ActivityThread.java:4745)
03-28 03:41:33.555: E/AndroidRuntime(622):  at java.lang.reflect.Method.invokeNative(Native Method)
03-28 03:41:33.555: E/AndroidRuntime(622):  at java.lang.reflect.Method.invoke(Method.java:511)
03-28 03:41:33.555: E/AndroidRuntime(622):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
03-28 03:41:33.555: E/AndroidRuntime(622):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
03-28 03:41:33.555: E/AndroidRuntime(622):  at dalvik.system.NativeStart.main(Native Method)
03-28 03:41:33.555: E/AndroidRuntime(622): Caused by: java.lang.RuntimeException: Libgdx requires OpenGL ES 2.0
03-28 03:41:33.555: E/AndroidRuntime(622):  at com.badlogic.gdx.backends.android.AndroidGraphics.createGLSurfaceView(AndroidGraphics.java:118)
03-28 03:41:33.555: E/AndroidRuntime(622):  at com.badlogic.gdx.backends.android.AndroidGraphics.<init>(AndroidGraphics.java:90)
03-28 03:41:33.555: E/AndroidRuntime(622):  at com.badlogic.gdx.backends.android.AndroidApplication.initialize(AndroidApplication.java:97)
03-28 03:41:33.555: E/AndroidRuntime(622):  at com.me.mygdxgame.MainActivity.onCreate(MainActivity.java:15)
03-28 03:41:33.555: E/AndroidRuntime(622):  at android.app.Activity.performCreate(Activity.java:5008)
03-28 03:41:33.555: E/AndroidRuntime(622):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
03-28 03:41:33.555: E/AndroidRuntime(622):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
03-28 03:41:33.555: E/AndroidRuntime(622):  ... 11 more
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

As @Sid notes in the comments, the error says LibGDX requires OpenGL ES 2.0 support. The emulator's software renderer does not support OpenGL ES 2.0.

You may be able to get your emulator to support by enabling graphics acceleration in the emulator. See http://developer.android.com/tools/devices/emulator.html#accel-graphics and Android OpenGL ES 2.0 emulator

Here is the Android Virtual Device Manager dialog with the setting highlighted. Enabling this definitely solves the problem on a Macbook Air, and likely many other computers.

Click Use Host GPU


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...