Libgdx cannot load texture issue

It is impossible to load the texture, it works fine, now it does not work, I do not know why.

import com.badlogic.gdx.graphics.Texture;

public class MiJuego implements ApplicationListener {
public Texture textura = new Texture(Gdx.files.internal("prueba.png"));

@Override
public void create() {
    // TODO Auto-generated method stub

}

An exception in the thread "main" java.lang.NullPointerException at com.alex.version1.MiJuego. (MiJuego.java:16) at com.alex.version1.Main.main (Main.java:14)

Line 16 is exactly the one in which I create the texture. I tested it in several projects, but it does not work. Images are installed in the resources folder in my android project.

+3
source share
1 answer

Try the following:

public class MiJuego implements ApplicationListener {
public Texture textura;

@Override
public void create() {
    textura = new Texture(Gdx.files.internal("prueba.png"))
    ...
}

ApplicationListener, . Libgdx . , Gdx.xxx NullPointerException.

+5

All Articles