0

I have an app and when I run it on desktop the assets are fine and it run correctly however when ever I try to run it on Android (emulator or apk on device) it forces close and i get the log cat error:

11-08 15:37:04.556: E/AndroidRuntime(1187): FATAL EXCEPTION: GLThread 90
11-08 15:37:04.556: E/AndroidRuntime(1187): Process: com.mkgame.game1.android, PID: 1187
11-08 15:37:04.556: E/AndroidRuntime(1187): com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: data/playButton2.png
11-08 15:37:04.556: E/AndroidRuntime(1187):     at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:140)
11-08 15:37:04.556: E/AndroidRuntime(1187):     at com.badlogic.gdx.graphics.glutils.FileTextureData.prepare(FileTextureData.java:64)
11-08 15:37:04.556: E/AndroidRuntime(1187):     at com.badlogic.gdx.graphics.Texture.load(Texture.java:130)
11-08 15:37:04.556: E/AndroidRuntime(1187):     at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:121)
11-08 15:37:04.556: E/AndroidRuntime(1187):     at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:100)
11-08 15:37:04.556: E/AndroidRuntime(1187):     at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:92)
11-08 15:37:04.556: E/AndroidRuntime(1187):     at com.MKgames.game1.screen.MainMenuScreen.<init>(MainMenuScreen.java:38)
11-08 15:37:04.556: E/AndroidRuntime(1187):     at com.MKgames.Game1.create(Game1.java:29)
11-08 15:37:04.556: E/AndroidRuntime(1187):     at com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:236)
11-08 15:37:04.556: E/AndroidRuntime(1187):     at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1512)
11-08 15:37:04.556: E/AndroidRuntime(1187):     at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
11-08 15:37:04.556: E/AndroidRuntime(1187): Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Error reading file: data/playButton2.png (Internal)
11-08 15:37:04.556: E/AndroidRuntime(1187):     at com.badlogic.gdx.backends.android.AndroidFileHandle.read(AndroidFileHandle.java:77)
11-08 15:37:04.556: E/AndroidRuntime(1187):     at com.badlogic.gdx.files.FileHandle.readBytes(FileHandle.java:220)
11-08 15:37:04.556: E/AndroidRuntime(1187):     at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:137)
11-08 15:37:04.556: E/AndroidRuntime(1187):     ... 10 more
11-08 15:37:04.556: E/AndroidRuntime(1187): Caused by: java.io.FileNotFoundException: data/playButton2.png
11-08 15:37:04.556: E/AndroidRuntime(1187):     at android.content.res.AssetManager.openAsset(Native Method)
11-08 15:37:04.556: E/AndroidRuntime(1187):     at android.content.res.AssetManager.open(AssetManager.java:316)
11-08 15:37:04.556: E/AndroidRuntime(1187):     at android.content.res.AssetManager.open(AssetManager.java:290)
11-08 15:37:04.556: E/AndroidRuntime(1187):     at com.badlogic.gdx.backends.android.AndroidFileHandle.read(AndroidFileHandle.java:75)
11-08 15:37:04.556: E/AndroidRuntime(1187):     ... 12 more

Herre is where I set the asset:

Texture playButtonTxture = new Texture(Gdx.files.internal("data/playButton2.png"));

I have looked at many other threads with similar topics and have tried the following things:

creating a data folder under assets refreshing the eclipse explorer Project > clean refreshing the gradles of the project triple checking file paths restarting the IDE removing capitals from the name of the asset (is this a myth or an actutal problem?)

The asset is in the data folder under the android assets with the correct name, I have tried multiple different combinations of solutions to no end.

Note - if I were to remove this asset and move on I believe I would get the same error with the next asset.

When I tried using a lower case assert name and changed the name of the asset in the android/asset/data folder and in the game and I got the same error:

11-09 13:51:50.623: E/AndroidRuntime(1118): FATAL EXCEPTION: GLThread 81
11-09 13:51:50.623: E/AndroidRuntime(1118): Process: com.mkgame.game1.android, PID: 1118
11-09 13:51:50.623: E/AndroidRuntime(1118): com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: data/play_button2.png
11-09 13:51:50.623: E/AndroidRuntime(1118):     at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:140)
11-09 13:51:50.623: E/AndroidRuntime(1118):     at com.badlogic.gdx.graphics.glutils.FileTextureData.prepare(FileTextureData.java:64)
11-09 13:51:50.623: E/AndroidRuntime(1118):     at com.badlogic.gdx.graphics.Texture.load(Texture.java:130)
11-09 13:51:50.623: E/AndroidRuntime(1118):     at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:121)
11-09 13:51:50.623: E/AndroidRuntime(1118):     at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:100)
11-09 13:51:50.623: E/AndroidRuntime(1118):     at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:92)
11-09 13:51:50.623: E/AndroidRuntime(1118):     at com.MKgames.game1.screen.MainMenuScreen.<init>(MainMenuScreen.java:38)
11-09 13:51:50.623: E/AndroidRuntime(1118):     at com.MKgames.Game1.create(Game1.java:29)
11-09 13:51:50.623: E/AndroidRuntime(1118):     at com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:236)
11-09 13:51:50.623: E/AndroidRuntime(1118):     at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1512)
11-09 13:51:50.623: E/AndroidRuntime(1118):     at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
11-09 13:51:50.623: E/AndroidRuntime(1118): Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Error reading file: data/play_button2.png (Internal)
11-09 13:51:50.623: E/AndroidRuntime(1118):     at com.badlogic.gdx.backends.android.AndroidFileHandle.read(AndroidFileHandle.java:77)
11-09 13:51:50.623: E/AndroidRuntime(1118):     at com.badlogic.gdx.files.FileHandle.readBytes(FileHandle.java:220)
11-09 13:51:50.623: E/AndroidRuntime(1118):     at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:137)
11-09 13:51:50.623: E/AndroidRuntime(1118):     ... 10 more
11-09 13:51:50.623: E/AndroidRuntime(1118): Caused by: java.io.FileNotFoundException: data/play_button2.png
11-09 13:51:50.623: E/AndroidRuntime(1118):     at android.content.res.AssetManager.openAsset(Native Method)
11-09 13:51:50.623: E/AndroidRuntime(1118):     at android.content.res.AssetManager.open(AssetManager.java:316)
11-09 13:51:50.623: E/AndroidRuntime(1118):     at android.content.res.AssetManager.open(AssetManager.java:290)
11-09 13:51:50.623: E/AndroidRuntime(1118):     at com.badlogic.gdx.backends.android.AndroidFileHandle.read(AndroidFileHandle.java:75)
11-09 13:51:50.623: E/AndroidRuntime(1118):     ... 12 more
useruseruser
  • 73
  • 1
  • 6

1 Answers1

0

I had a similar problem, when I implemented Google Play Services Library the wrong way. It also contains an assets-folder and my Android project was somehow linked to that folder.

So if you have Google Play Services implemented, try removing it and see if that works. Then add it to the project the right way.

Hope this helps!

ADDER
  • 404
  • 3
  • 5
  • http://theinvader360.blogspot.fi/2013/10/google-play-game-services-tutorial-example.html – ADDER Nov 13 '14 at 13:21