3

This is my first time using libgdx and I would like to try the default application provided after the setup gdx-setup-ui. It runs fine when I hit the run button on eclipse as it has shown

[2014-05-01 21:40:14 - my-gdx-game-android] Uploading my-gdx-game-android.apk onto device 'emulator-5554'
[2014-05-01 21:40:15 - my-gdx-game-android] Installing my-gdx-game-android.apk...
[2014-05-01 21:40:16 - my-gdx-game-android] Success!
[2014-05-01 21:40:16 - my-gdx-game-android] Starting activity com.me.mygdxgame.MainActivity on device emulator-5554
[2014-05-01 21:40:16 - my-gdx-game-android] ActivityManager: WARNING: linker: libdvm.so has text relocations. This is wasting memory and is a security risk. Please fix.
[2014-05-01 21:40:16 - my-gdx-game-android] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.me.mygdxgame/.MainActivity }

but on the emulator it said unfortunately, my LibGDX Game has stopped.

These are shown in the logCat:

05-01 17:02:04.936: D/dalvikvm(2034): Trying to load lib /data/app-lib/com.me.mygdxgame-1/libgdx.so 0xb103cb78
05-01 17:02:04.936: D/dalvikvm(2034): Added shared lib /data/app-lib/com.me.mygdxgame-1/libgdx.so 0xb103cb78
05-01 17:02:04.936: D/dalvikvm(2034): No JNI_OnLoad found in /data/app-lib/com.me.mygdxgame-1/libgdx.so 0xb103cb78, skipping init
05-01 17:02:04.936: D/AndroidRuntime(2034): Shutting down VM
05-01 17:02:04.936: W/dalvikvm(2034): threadid=1: thread exiting with uncaught exception (group=0xb0d34b20)
05-01 17:02:04.996: E/AndroidRuntime(2034): FATAL EXCEPTION: main
05-01 17:02:04.996: E/AndroidRuntime(2034): Process: com.me.mygdxgame, PID: 2034
05-01 17:02:04.996: E/AndroidRuntime(2034): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.me.mygdxgame/com.me.mygdxgame.MainActivity}: com.badlogic.gdx.utils.GdxRuntimeException: Libgdx requires OpenGL ES 2.0
05-01 17:02:04.996: E/AndroidRuntime(2034):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
05-01 17:02:04.996: E/AndroidRuntime(2034):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
05-01 17:02:04.996: E/AndroidRuntime(2034):     at android.app.ActivityThread.access$800(ActivityThread.java:135)
05-01 17:02:04.996: E/AndroidRuntime(2034):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
05-01 17:02:04.996: E/AndroidRuntime(2034):     at android.os.Handler.dispatchMessage(Handler.java:102)
05-01 17:02:04.996: E/AndroidRuntime(2034):     at android.os.Looper.loop(Looper.java:136)
05-01 17:02:04.996: E/AndroidRuntime(2034):     at android.app.ActivityThread.main(ActivityThread.java:5017)
05-01 17:02:04.996: E/AndroidRuntime(2034):     at java.lang.reflect.Method.invokeNative(Native Method)
05-01 17:02:04.996: E/AndroidRuntime(2034):     at java.lang.reflect.Method.invoke(Method.java:515)
05-01 17:02:04.996: E/AndroidRuntime(2034):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
05-01 17:02:04.996: E/AndroidRuntime(2034):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
05-01 17:02:04.996: E/AndroidRuntime(2034):     at dalvik.system.NativeStart.main(Native Method)
05-01 17:02:04.996: E/AndroidRuntime(2034): Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Libgdx requires OpenGL ES 2.0
05-01 17:02:04.996: E/AndroidRuntime(2034):     at com.badlogic.gdx.backends.android.AndroidGraphics.createGLSurfaceView(AndroidGraphics.java:121)
05-01 17:02:04.996: E/AndroidRuntime(2034):     at com.badlogic.gdx.backends.android.AndroidGraphics.<init>(AndroidGraphics.java:101)
05-01 17:02:04.996: E/AndroidRuntime(2034):     at com.badlogic.gdx.backends.android.AndroidGraphics.<init>(AndroidGraphics.java:94)
05-01 17:02:04.996: E/AndroidRuntime(2034):     at com.badlogic.gdx.backends.android.AndroidApplication.init(AndroidApplication.java:130)
05-01 17:02:04.996: E/AndroidRuntime(2034):     at com.badlogic.gdx.backends.android.AndroidApplication.initialize(AndroidApplication.java:96)
05-01 17:02:04.996: E/AndroidRuntime(2034):     at com.me.mygdxgame.MainActivity.onCreate(MainActivity.java:15)
05-01 17:02:04.996: E/AndroidRuntime(2034):     at android.app.Activity.performCreate(Activity.java:5231)
05-01 17:02:04.996: E/AndroidRuntime(2034):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
05-01 17:02:04.996: E/AndroidRuntime(2034):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
05-01 17:02:04.996: E/AndroidRuntime(2034):     ... 11 more

Also, I have deleted the line cfg.useGL20 = true; in the MainActivity.java as it keeps giving me error and I tried to quick fix it, it does not work. I really need it to be used in an emulator as I does not own at android device.

vjdhama
  • 4,878
  • 5
  • 33
  • 47
  • 1
    I think Android Emulator not support OpenGL ES 2.0 and LibGDX does not support < OpenGL ES 2.0 since version 1.0, you should test on a device or Genymotion. If you run on Emulator I found this post maybe useful for you [ANDROID EMULATOR NOW SUPPORTS NATIVE OPENGL ES2.0!](http://www.learnopengles.com/android-emulator-now-supports-native-opengl-es2-0/) – Phonbopit May 02 '14 at 01:59
  • 1
    possible duplicate of [LibGDX Hello-World Project does not work](http://stackoverflow.com/questions/22703940/libgdx-hello-world-project-does-not-work) – P.T. May 02 '14 at 03:59
  • Oh my god, genymotion has worked fine for me! Thanks for the reply :D – SourCreamOnion May 02 '14 at 21:30

1 Answers1

5

I was able to make this work on a Macbook Air by:

  1. open the Android Virtual Device Manager (e.g. in Eclipse this is under the Window menu)
  2. click Edit for the device you want to work with
  3. in the resulting dialog check the box "Use Host GPU" as shown

Click Use Host GPU

Save and try again.

I'm guessing this depends on your computer's graphics card support OpenGL2.0, but I also suspect that this is pretty common nowadays.

mm2001
  • 6,427
  • 5
  • 39
  • 37