Reputation: 19
Hi i have problem with android run my project in LibGDX, in desktop run works everythink all right. My working direktory in desktop is in location "ProjecktGKLibGDX\android\assets" (so the same as android default), when i run projekt in android aplikation, it crash with error than one of the file can't be found (menu.png). I use atlas for the Sprites, it work like this: atlas= new TextureAtlas("Menu.atlas"); and this is my atlas file :
menu.png
format: RGBA8888
filter: Nearest,Nearest
repeat: none
EXIT
rotate: false
xy: 1, 418
size: 900, 415
orig: 900, 415
offset: 0, 0
index: -1
LOAD
rotate: false
xy: 1, 1
size: 900, 415
orig: 900, 415
offset: 0, 0
index: -1
menu2.png
format: RGBA8888
filter: Nearest,Nearest
repeat: none
PLAY
rotate: false
xy: 1, 418
size: 900, 415
orig: 900, 415
offset: 0, 0
index: -1
SAVE
rotate: false
xy: 1, 1
size: 900, 415
orig: 900, 415
offset: 0, 0
index: -1
menu3.png
format: RGBA8888
filter: Nearest,Nearest
repeat: none
open_menu
rotate: false
xy: 1, 1
size: 512, 512
orig: 512, 512
offset: 0, 0
index: -1
Atlas and png images are in the same folder ("ProjecktGKLibGDX\android\assets"), soo android can read Atlas file but can't read png files.
com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: menu.PNG
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Error reading file: menu.PNG (Internal)
Caused by: java.io.FileNotFoundException: menu.PNG
Upvotes: 0
Views: 89
Reputation: 109
Maybe It happens because menu.PNG doesn't exist. Check your assets and make sure that your file name is "menu.PNG".
Upvotes: 0
Reputation: 1517
Your error message "Error reading file: menu.PNG (Internal)" implies it might have to do with using the LibGDX file type "Internal". If you create a TextureAtlas with a string it automatically creates the atlas using the "Internal" file type. https://libgdx.badlogicgames.com/ci/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/TextureAtlas.html#TextureAtlas-java.lang.String-
On desktop the Internal and Local file types do essentially the same thing so these don't matter, but on Android they are different. You can read more about the different file types here: https://github.com/libgdx/libgdx/wiki/File-handling
Try changing the line:
atlas= new TextureAtlas("Menu.atlas");
To:
atlas = new TextureAtlas(Gdx.files.local("Menu.atlas"));
Upvotes: 1