JavaNoobie
JavaNoobie

Reputation: 23

AndroidRuntime﹕ FATAL EXCEPTION: main (libGDX

I am pretty new to programming and I am struggling with the next problem. I am using LibGDX to create a Tiled based game (following tutorials). Now the desktop part is all going fine, and working like it should. But when i try to run the android part it instantly crashes. Below my logcat and the codes. Need any more info please let me know. Any help is welcome.

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

Below my launcher:

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);
 }
}

Upvotes: 0

Views: 427

Answers (1)

dHoja
dHoja

Reputation: 206

If you are using a emulator the emulator might be the problem.

As you can see here:

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

It says that Libgdx requires Open GL 2.0. This is a common error when dealing with emulators. Try to use an older version of the emulator (Lower then API 19) and see if it will work. If you have a android phone you might also try to run it there. (I'm assuming that you are using an emulator).

Similar issues have been reported here and here.

Upvotes: 1

Related Questions