[libGDX] Can't localize assets folder with files

Hello,

I have problem with assets folder in my project.
I have line with localization of badlogic.jpg:

javaimg = new Texture("badlogic.jpg");

If I have this jpg file in ‘assets’ folder (in core), that java doesn’t see this file. I have to put this file in main folder of my project.
I have seen a lot of tutorials where people had this file in ‘assets’ folder and they use this kind of localization “badlogic.jpg”.
Where did I make a mistake?

Hi,

You need to tell libgdx to use the internal folder, which is the assets folder.
The path you’ve given is correct, but you also need to call

Gdx.files.internal("")

In your case it should look more like this:


javaimg = new Texture(Gdx.files.internal("badlogic.jpg"));

There is some official documentation about managing assets with LibGDX.

I wrote a tutorial about my solution here if you want to check it out :slight_smile:

+1 stampler

The texture doesn’t take the string but the resolved string or the resolver that links to the string… Whatever…

Internal - is your assets and are read only (at least on android)
Local - is the private area for your app to save files.

The rest, I’m sure they have their uses, but I don’t think you’d want to use for distribution.

Oh… Almost forgot, you may have forgotten the step of ensuring that the compiler is looking at your android assets folder,