0

My game runs correctly when I test the desktop version, but when I launch an android emulator and and try to run the game on the emulator the game closes and I get the logcat errors:

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

I understand that the error migh be obvious that the file is not found, but it should be as it's location is fine and when i run it as a desktop app the file is fine (I copied all of my desktop assets into the android assets, they there are exactly the same). So what could the problem be?

Here is where i set the image:

Texture playButtonTxture = new Texture(Gdx.files.internal("playButton2.png"));
useruseruser
  • 73
  • 1
  • 6
  • have you tested the app on the real device ? emulators are unreliable – Aashish Bhatnagar Oct 28 '14 at 12:09
  • @AashishVirendraKBhatnagar I have exported my app apk to my android phone and it still forces close – useruseruser Oct 28 '14 at 12:11
  • http://stackoverflow.com/questions/25138314/com-badlogic-gdx-utils-gdxruntimeexception-couldnt-load-file-error this may help all the best – Aashish Bhatnagar Oct 28 '14 at 12:13
  • @AashishVirendraKBhatnagar Would this be where it is looking for the png? at android.content.res.AssetManager.openAsset(Native Method) because it is in the android assets folder so i think that would be incorrect? If that is the case how would I then change where it looks for the file? thanks – useruseruser Oct 28 '14 at 12:21
  • @AashishVirendraKBhatnagar pls c updatre – useruseruser Oct 28 '14 at 12:26
  • @useruseruser What folder in your project did you put playButton2.png? I recommend you put it in assets/data, then instead of "playButton2.png" it should be "data/playButton2.png" – ilikeyoyo Nov 05 '14 at 00:11

1 Answers1

0

your use.

texture = new Texture (Gdx.files.internal("YourPath/YourFile.png"));

other hand, emulators use virtual disk "to know where they keep things :)" no seriously maybe the error comes from there.

Edit: in your package explorer

asssets-->yourfile.png

or

assets-->yourFolder-->yourfile.png

NEW: Your mistake is that in the draft you have android as nombre.png is a windows shortcut to the photo and delete them photo copy, if you do be sure to press the dragging I think windows control was also to copy

Angel Angel
  • 19,670
  • 29
  • 79
  • 105