0
votes

I'm trying to create a game with libgdx. The game works well when I'm testing it inside Eclipse but when I try to export it either for android or desktop the game starts and crashes immediately.

The problem is that the game cannot find the Assets and thus it throws an unhandled exception. I use the following way to load all of my assets.

 mainmenu = new Sprite(new Texture(Gdx.files.internal("Images/Screens/MainMenu.png")));

I have searched the exported jar and all the assets are properly located inside it, yet for some reason the game cannot find them. On the desktop it will work fine when I place the .jar file into my assets folder.

When I create a new libgdx project and export it, it works fine, but as soon as I add my java classes it stops working.

I have tried searching for similar questions here, but none of the answers solved my problem.

2

2 Answers

0
votes

It can be that a file is inside the assets folder that is not wanted.

I had a similar problem, in my assets folder was a .xcf file a gimp file. I deleted the .xcf file and the problem was solved.

0
votes

I have found the solution, so I'm answering my own question in case someone else has the same problem.

I had a an image inside the assets folder with the extension .PNG and in my source code I was trying to read it as .png

Because I'm on Linux which is a case sensitive OS this was causing a runtime exception. Same thing for the android export.