NPE when trying to reference MyGame.app from nifty ScreenController

I have a public static MyGame app reference on MyGame, which is set in the main method as follows:

[java]
public static void main(String[] args){
MyGame.app = new MyGame();
MyGame.app.start();
}
[/java]

In a nifty ScreenController, attempts to reference data on MyGame.app results in a NullPointerException, but only on my Android device.

The desktop version doesn’t have suffer from this problem, so it seems like an Android specific problem.

Any ideas as to what’s going wrong here, and how to fix it?

main() is only run on Desktop not on android.

Anyway, setting the static member is probably something you want to do in simpleInit() anyway.

android has no main

Oh, I see.

Thanks!

1 Like