0
當我測試桌面版本時,我的遊戲運行正常,但是當我啓動一個android模擬器並嘗試在模擬器上運行遊戲時,遊戲關閉,並且出現logcat錯誤:致命異常:GLThread 84:FileNotFoundException Android logcat錯誤
10-28 08:00:53.528: E/AndroidRuntime(1203): FATAL EXCEPTION: GLThread 84
10-28 08:00:53.528: E/AndroidRuntime(1203): Process: com.mkgame.game1.android, PID: 1203
10-28 08:00:53.528: E/AndroidRuntime(1203): com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: playButton2.png
10-28 08:00:53.528: E/AndroidRuntime(1203): at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:140)
10-28 08:00:53.528: E/AndroidRuntime(1203): at com.badlogic.gdx.graphics.glutils.FileTextureData.prepare(FileTextureData.java:64)
10-28 08:00:53.528: E/AndroidRuntime(1203): at com.badlogic.gdx.graphics.Texture.load(Texture.java:130)
10-28 08:00:53.528: E/AndroidRuntime(1203): at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:121)
10-28 08:00:53.528: E/AndroidRuntime(1203): at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:100)
10-28 08:00:53.528: E/AndroidRuntime(1203): at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:92)
10-28 08:00:53.528: E/AndroidRuntime(1203): at com.MKgames.game1.screen.MainMenuScreen.<init>(MainMenuScreen.java:38)
10-28 08:00:53.528: E/AndroidRuntime(1203): at com.MKgames.Game1.create(Game1.java:29)
10-28 08:00:53.528: E/AndroidRuntime(1203): at com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:236)
10-28 08:00:53.528: E/AndroidRuntime(1203): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1512)
10-28 08:00:53.528: E/AndroidRuntime(1203): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
10-28 08:00:53.528: E/AndroidRuntime(1203): Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Error reading file: playButton2.png (Internal)
10-28 08:00:53.528: E/AndroidRuntime(1203): at com.badlogic.gdx.backends.android.AndroidFileHandle.read(AndroidFileHandle.java:77)
10-28 08:00:53.528: E/AndroidRuntime(1203): at com.badlogic.gdx.files.FileHandle.readBytes(FileHandle.java:220)
10-28 08:00:53.528: E/AndroidRuntime(1203): at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:137)
10-28 08:00:53.528: E/AndroidRuntime(1203): ... 10 more
10-28 08:00:53.528: E/AndroidRuntime(1203): Caused by: java.io.FileNotFoundException: playButton2.png
10-28 08:00:53.528: E/AndroidRuntime(1203): at android.content.res.AssetManager.openAsset(Native Method)
10-28 08:00:53.528: E/AndroidRuntime(1203): at android.content.res.AssetManager.open(AssetManager.java:316)
10-28 08:00:53.528: E/AndroidRuntime(1203): at android.content.res.AssetManager.open(AssetManager.java:290)
10-28 08:00:53.528: E/AndroidRuntime(1203): at com.badlogic.gdx.backends.android.AndroidFileHandle.read(AndroidFileHandle.java:75)
10-28 08:00:53.528: E/AndroidRuntime(1203): ... 12 more
我的理解是錯誤migh顯而易見的是,文件沒有找到,但它應該是因爲它的位置就可以了,當我運行它作爲一個桌面應用程序的文件是好的(我複製了所有的我的桌面資產進入Android資產,他們有完全一樣的)。 那麼問題是什麼?
這裏是我設置的圖像:
Texture playButtonTxture = new Texture(Gdx.files.internal("playButton2.png"));
您是否在真實設備上測試過應用程序?模擬器是不可靠的 – 2014-10-28 12:09:01
@AashishVirendraKBhatnagar我已經將我的應用程序apk導出到我的android手機,它仍然強制關閉 – useruseruser 2014-10-28 12:11:09
http://stackoverflow.com/questions/25138314/com-badlogic-gdx-utils-gdxruntimeexception-couldnt-load-file-錯誤,這可能會幫助所有最好的 – 2014-10-28 12:13:47