-1

i have a Problem with my game app:

It crashes if you minimize it... e.g. if you press the home button or click on ads. Here is the Log:

>threadid=19: thread exiting with uncaught exception (group=0x417f2da0)
08-26 23:42:38.207 17397 17478 E AndroidRuntime FATAL EXCEPTION: Thread-38883
08-26 23:42:38.207 17397 17478 E AndroidRuntime Process: de.lolxdfly.flypig, PID: 17397
08-26 23:42:38.207 17397 17478 E AndroidRuntime java.lang.NullPointerException
08-26 23:42:38.207 17397 17478 E AndroidRuntime at de.lolxdfly.flypig.GameView.onDraw(GameView.java:87)
08-26 23:42:38.207 17397 17478 E AndroidRuntime at de.lolxdfly.flypig.GameLoopThread.run(GameLoopThread.java:34)

I use the code from this TuT: http://panjutorials.de/tutorials/android-gameapp-entwicklungstutorial-lazy-pudding/

Mfg lolxdfly

==================== Edit: I fixed the crash, but if i resume the all rects are set to 0, except the rects for the pause menu. The pause menu is also opened. It is possible, that some happen with the canvas if the app is paused?

lolxdfly
  • 381
  • 1
  • 3
  • 13
  • possible duplicate of [What is a stack trace, and how can I use it to debug my application errors?](http://stackoverflow.com/questions/3988788/what-is-a-stack-trace-and-how-can-i-use-it-to-debug-my-application-errors) – panini Aug 26 '14 at 22:05
  • It's definitely not a duplicate of how to debug with stack trace! – lolxdfly Aug 26 '14 at 22:15
  • 2
    Does it crash when you leave the app, or only when you come back to it? What did you find when you tracked down the code at the point where it crashed? – David Conrad Aug 26 '14 at 22:18
  • I'm guessing you aren't restoring your `GameView` state after the activity is reconstructed. – chrylis -cautiouslyoptimistic- Aug 26 '14 at 23:02
  • It crashes directly after it minimize... If i come back to the app the app restarts(because it was shutdown when it was minimized) – lolxdfly Aug 27 '14 at 10:07

1 Answers1

0

You have a NullPointerException at line 87 of your GameView.java

It may be possible that some objects are garbage collected while the Thread is still running when you minimize the game.

BrainCrash
  • 12,992
  • 3
  • 32
  • 38