NullPointerException

  ... in the unlikely case you discovered a bug, post it here.

NullPointerException

Postby sake » Tue Jan 03, 2012 1:32 pm

Hello there. Sometimes it occurs that in BaseGameActivity this part here:

Code: Select all
@Override
   public void onResumeGame() {
      Debug.d(this.getClass().getSimpleName() + ".onResumeGame" + " @(Thread: '" + Thread.currentThread().getName() + "')");

      this.mEngine.start();

      this.mGamePaused = false;
   }


is being executed without mEngine being initialized (at game startup). Can that be because of the debugging process (Old Thread not being killed completely and for that reason onResumeGame being called?)
BlockBreaker
BlockBreaker @ Google Play!

Everything I post here is licensed under the Beerware License.
sake
 
Posts: 67
Joined: Sun Dec 11, 2011 3:15 pm
Location: Guttenthau, Germany

Re: NullPointerException

Postby dorasoft » Tue Jan 03, 2012 5:22 pm

I think it's because the life cycle of the program (I copy following text from another post)?

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. 01-01 17:40:49.057: D/AndEngine(11026): Menu.onPause @(Thread: 'main')
  2. 01-01 17:40:49.087: D/AndEngine(11026): Menu.onPauseGame @(Thread: 'main')
  3. 01-01 17:40:49.107: D/AndEngine(11026): Main.onCreate @(Thread: 'main')
  4. 01-01 17:40:49.107: D/AndEngine(11026): Main.onResume @(Thread: 'main')
  5. 01-01 17:40:49.197: D/AndEngine(11026): Main.onSurfaceCreated @(Thread: 'GLThread 130')
  6. 01-01 17:40:49.197: D/AndEngine(11026): Main.onCreateGame @(Thread: 'GLThread 130')
  7. 01-01 17:40:49.197: D/AndEngine(11026): Main.onCreateResources @(Thread: 'GLThread 130')
  8. 01-01 17:40:49.207: D/AndEngine(11026): Menu.onDestroy @(Thread: 'main')
  9. 01-01 17:40:49.207: D/AndEngine(11026): Menu.onDestroyResources @(Thread: 'main')
  10. 01-01 17:40:49.207: D/AndEngine(11026): Menu.onGameDestroyed @(Thread: 'main')
  11. 01-01 17:40:49.227: D/AndEngine(11026): Main.onCreateScene @(Thread: 'GLThread 130')
  12. 01-01 17:40:49.227: D/AndEngine(11026): Main.onPopulateScene @(Thread: 'GLThread 130')
  13. 01-01 17:40:49.237: D/AndEngine(11026): Main.onGameCreated @(Thread: 'GLThread 130')
  14. 01-01 17:40:49.237: D/AndEngine(11026): Main.onResumeGame @(Thread: 'main')
Parsed in 0.036 seconds, using GeSHi 1.0.8.4


I guess onResume occurs before onCreateGame, so mEngine hasn't been initialized yet. Maybe you should add conditional structure here:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.       if (this.mEngine != null)
  2.             this.mEngine.start();
  3.  
  4.       this.mGamePaused = false;
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
dorasoft
 
Posts: 87
Joined: Sat Jun 18, 2011 4:06 pm

Re: NullPointerException

Postby sake » Tue Jan 03, 2012 11:34 pm

This is a bug in the whole repository. This is in the AndEngine class. So this should be fixed as fast as possible!
BlockBreaker
BlockBreaker @ Google Play!

Everything I post here is licensed under the Beerware License.
sake
 
Posts: 67
Joined: Sun Dec 11, 2011 3:15 pm
Location: Guttenthau, Germany


Return to Bugs

Who is online

Users browsing this forum: No registered users and 2 guests