libgdx android 启动失败

Posted

技术标签:

【中文标题】libgdx android 启动失败【英文标题】:libgdx android failed on launch 【发布时间】:2014-06-18 11:18:53 【问题描述】:

这是我第一次使用 libgdx,我想尝试在设置 gdx-setup-ui 之后提供的默认应用程序。当我点击 Eclipse 上的运行按钮时,它运行良好,正如它所显示的那样

[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 

但不幸的是,在模拟器上,我的LibGDX 游戏已停止。

这些都显示在 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 ComponentInfocom.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

另外,我删除了MainActivity.java 中的cfg.useGL20 = true; 行,因为它一直给我错误,我试图快速修复它,但它不起作用。我真的需要在模拟器中使用它,因为我没有在 android 设备上拥有它。

【问题讨论】:

我认为 Android Emulator 不支持 OpenGL ES 2.0 并且 LibGDX 不支持 ANDROID EMULATOR NOW SUPPORTS NATIVE OPENGL ES2.0! LibGDX Hello-World Project does not work的可能重复 天哪,genymotion 对我来说效果很好!感谢您的回复:D 【参考方案1】:

我能够通过以下方式在 Macbook Air 上完成这项工作:

    打开 Android 虚拟设备管理器(例如,在 Eclipse 中,它位于 Window 菜单下) 点击您要使用的设备的编辑 在出现的对话框中选中“使用主机 GPU”框,如图所示

保存并重试。

我猜这取决于您计算机的显卡是否支持 OpenGL2.0,但我也怀疑这在当今很普遍。

【讨论】:

以上是关于libgdx android 启动失败的主要内容,如果未能解决你的问题,请参考以下文章

Android 相机启动预览失败

Android Studio ADB启动失败解决方法

由于插件com.android.application启动失败

禁用启动器活动后,android重新安装失败

Android ADB Server启动失败

Android 媒体录制:java.lang.RuntimeException:启动失败