I have an Android app modeled after an example LunarLanderfrom Google. I am debugging it on a real device, ( Motorola Droid) using Android 2.0. When the orientation changes, the program crashes on NullPointerException. Logcat from before crash:
02-01 00:24:27.956: DEBUG/nate(8358): Starting Game
02-01 00:24:36.878: DEBUG/dalvikvm(1086): GC freed 1788 objects / 92256 bytes in 1389ms
02-01 00:24:38.542: INFO/WindowManager(1021): Setting rotation to 1, animFlags=0
02-01 00:24:38.558: INFO/ActivityManager(1021): Config changed: { scale=1.0 imsi=310/4 loc=en_US touch=3 keys=2/1/2 nav=2/2 orien=2 layout=34}
02-01 00:24:38.620: WARN/UsageStats(1021): Something wrong here, didnt expect org.nifong.leeder to be resumed
02-01 00:24:38.886: DEBUG/nate(8358): New Surface dimensions: 854x442
02-01 00:24:38.886: DEBUG/nate(8358): flies was null
The first line that worries me is "Something wrong here"at 24:38.620. I have no idea what this means, but I think that because of this I am not responding properly to changing the screen.
Next, I get a debugging message that I typed from my own method surfaceChanged()about new surface sizes.
Then I print out a debugging message about whether there were flies null. fliesis the field that ultimately causes NullPointerException. It was created once and is never written again for the rest of the program. I know that this was not a mistake before the collapse, because it was read several times.
Does anyone know how my private member variable became null only with these hints?
I would include the code, but there is a lot of it, and I do not know what will be relevant.
source
share