Libgdx游戏在Android手机上崩溃

时间:2014-04-03 15:18:09

标签: android libgdx runtime-error game-engine

我创建了一个在桌面上完美运行但在Android手机上崩溃并出现以下错误的示例游戏。

**Unfortunately, My LibGDX Game has stopped.**

我已经使用两种不同的手机甚至模拟器进行了测试,但错误仍然相同。以下是Android版本的项目属性。

Project Properties for Android Version

LogCat是(带错误过滤器):

04-03 21:55:41.582: E/Trace(20583): error opening trace file: No such file or directory (2)
04-03 21:55:42.022: E/MediaPlayerService(224): [MediaPlayerService getPlayerType:fd] GetPlayerSetup[Defaults/Video:MaxWidth] = 1920
04-03 21:55:42.022: E/MediaPlayerService(224): [MediaPlayerService getPlayerType:fd] GetPlayerSetup[DivXs/Video:MaxWidth] = 1920
04-03 21:55:42.022: E/MediaPlayerService(224): [MediaPlayerService getPlayerType:fd] GetPlayerSetup[Rtsps/UserAgent:Default] = Player/LG Player 1.0 for Android(stagefright alternative)
04-03 21:55:42.022: E/MediaPlayerService(224): [MediaPlayerService getPlayerType:fd] GetPlayerSetup[Https/Streaming:PowerSave] = true
04-03 21:55:42.022: E/MediaPlayerService(224): [MediaPlayerService getPlayerType:fd] PlayerManager.GetPlayerType = 3
04-03 21:55:42.042: E/MetadataRetrieverClient(224): failed to extract an album art
04-03 21:55:42.052: E/MediaPlayerService(224): [MediaPlayerService getPlayerType:fd] GetPlayerSetup[Defaults/Video:MaxWidth] = 1920
04-03 21:55:42.052: E/MediaPlayerService(224): [MediaPlayerService getPlayerType:fd] GetPlayerSetup[DivXs/Video:MaxWidth] = 1920
04-03 21:55:42.052: E/MediaPlayerService(224): [MediaPlayerService getPlayerType:fd] GetPlayerSetup[Rtsps/UserAgent:Default] = Player/LG Player 1.0 for Android(stagefright alternative)
04-03 21:55:42.052: E/MediaPlayerService(224): [MediaPlayerService getPlayerType:fd] GetPlayerSetup[Https/Streaming:PowerSave] = true
04-03 21:55:42.052: E/MediaPlayerService(224): [MediaPlayerService getPlayerType:fd] PlayerManager.GetPlayerType = 3
04-03 21:55:42.073: E/MetadataRetrieverClient(224): failed to extract an album art
04-03 21:55:42.543: E/AndroidRuntime(20583): FATAL EXCEPTION: GLThread 666
04-03 21:55:42.543: E/AndroidRuntime(20583): com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: images/smountains.png
04-03 21:55:42.543: E/AndroidRuntime(20583):    at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:140)
04-03 21:55:42.543: E/AndroidRuntime(20583):    at com.badlogic.gdx.graphics.glutils.FileTextureData.prepare(FileTextureData.java:64)
04-03 21:55:42.543: E/AndroidRuntime(20583):    at com.badlogic.gdx.graphics.Texture.load(Texture.java:175)
04-03 21:55:42.543: E/AndroidRuntime(20583):    at com.badlogic.gdx.graphics.Texture.create(Texture.java:159)
04-03 21:55:42.543: E/AndroidRuntime(20583):    at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:133)
04-03 21:55:42.543: E/AndroidRuntime(20583):    at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:122)
04-03 21:55:42.543: E/AndroidRuntime(20583):    at com.shoayb.defendearth.view.WorldRenderer.loadTextures(WorldRenderer.java:77)
04-03 21:55:42.543: E/AndroidRuntime(20583):    at com.shoayb.defendearth.view.WorldRenderer.<init>(WorldRenderer.java:67)
04-03 21:55:42.543: E/AndroidRuntime(20583):    at com.shoayb.defendearth.screens.GameScreen.show(GameScreen.java:15)
04-03 21:55:42.543: E/AndroidRuntime(20583):    at com.badlogic.gdx.Game.setScreen(Game.java:59)
04-03 21:55:42.543: E/AndroidRuntime(20583):    at com.shoayb.defendearth.DefendEarth.create(DefendEarth.java:8)
04-03 21:55:42.543: E/AndroidRuntime(20583):    at com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:292)
04-03 21:55:42.543: E/AndroidRuntime(20583):    at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1505)
04-03 21:55:42.543: E/AndroidRuntime(20583):    at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
04-03 21:55:42.543: E/AndroidRuntime(20583): Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Error reading file: images/smountains.png (Internal)
04-03 21:55:42.543: E/AndroidRuntime(20583):    at com.badlogic.gdx.backends.android.AndroidFileHandle.read(AndroidFileHandle.java:67)
04-03 21:55:42.543: E/AndroidRuntime(20583):    at com.badlogic.gdx.files.FileHandle.length(FileHandle.java:561)
04-03 21:55:42.543: E/AndroidRuntime(20583):    at com.badlogic.gdx.backends.android.AndroidFileHandle.length(AndroidFileHandle.java:149)
04-03 21:55:42.543: E/AndroidRuntime(20583):    at com.badlogic.gdx.files.FileHandle.readBytes(FileHandle.java:221)
04-03 21:55:42.543: E/AndroidRuntime(20583):    at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:137)
04-03 21:55:42.543: E/AndroidRuntime(20583):    ... 13 more
04-03 21:55:42.543: E/AndroidRuntime(20583): Caused by: java.io.FileNotFoundException: images/smountains.png
04-03 21:55:42.543: E/AndroidRuntime(20583):    at android.content.res.AssetManager.openAsset(Native Method)
04-03 21:55:42.543: E/AndroidRuntime(20583):    at android.content.res.AssetManager.open(AssetManager.java:315)
04-03 21:55:42.543: E/AndroidRuntime(20583):    at android.content.res.AssetManager.open(AssetManager.java:289)
04-03 21:55:42.543: E/AndroidRuntime(20583):    at com.badlogic.gdx.backends.android.AndroidFileHandle.read(AndroidFileHandle.java:65)
04-03 21:55:42.543: E/AndroidRuntime(20583):    ... 17 more
04-03 21:55:43.324: E/MediaPlayerService(224): [MediaPlayerService getPlayerType:fd] GetPlayerSetup[Defaults/Video:MaxWidth] = 1920
04-03 21:55:43.324: E/MediaPlayerService(224): [MediaPlayerService getPlayerType:fd] GetPlayerSetup[DivXs/Video:MaxWidth] = 1920
04-03 21:55:43.324: E/MediaPlayerService(224): [MediaPlayerService getPlayerType:fd] GetPlayerSetup[Rtsps/UserAgent:Default] = Player/LG Player 1.0 for Android(stagefright alternative)
04-03 21:55:43.324: E/MediaPlayerService(224): [MediaPlayerService getPlayerType:fd] GetPlayerSetup[Https/Streaming:PowerSave] = true
04-03 21:55:43.324: E/MediaPlayerService(224): [MediaPlayerService getPlayerType:fd] PlayerManager.GetPlayerType = 3
04-03 21:55:43.354: E/MetadataRetrieverClient(224): failed to extract an album art
04-03 21:55:43.364: E/MessageUtils(12466): [LGE]isMmsMemoryAvailable/freeSpace:6233837568/threshold:2097152
04-03 21:55:43.404: E/MediaPlayerService(224): [MediaPlayerService getPlayerType:fd] GetPlayerSetup[Defaults/Video:MaxWidth] = 1920
04-03 21:55:43.404: E/MediaPlayerService(224): [MediaPlayerService getPlayerType:fd] GetPlayerSetup[DivXs/Video:MaxWidth] = 1920
04-03 21:55:43.404: E/MediaPlayerService(224): [MediaPlayerService getPlayerType:fd] GetPlayerSetup[Rtsps/UserAgent:Default] = Player/LG Player 1.0 for Android(stagefright alternative)
04-03 21:55:43.404: E/MediaPlayerService(224): [MediaPlayerService getPlayerType:fd] GetPlayerSetup[Https/Streaming:PowerSave] = true
04-03 21:55:43.404: E/MediaPlayerService(224): [MediaPlayerService getPlayerType:fd] PlayerManager.GetPlayerType = 3
04-03 21:55:43.434: E/MetadataRetrieverClient(224): failed to extract an album art

1 个答案:

答案 0 :(得分:0)

谢谢大家:)问题解决了。实际上文件名是

  

“smountains.PNG”

在主libgdx项目中,我使用

语法
  

sMountainTexture=new Texture(Gdx.files.internal("images/smountains.png"));

案例“png”和“PNG”的区别在Desktop Project的情况下无关紧要,但在Android版本中被视为错误。再次感谢每个人的帮助。