Android Question NullPointerException in Debug Mode but not when compiled

Gary Milne

Active Member
Licensed User
Longtime User
I have an app I've written that I'm going through some final testing on before release.

When in Debug mode I will often get NullPointerExceptions on the 2nd or 3rd launch of the Activity. However, once it is compiled into Release mode these errors go away and I can launch the app 10 times in a row without error.

My conclusion is that the debugger has some flaws that are being highlighted, however it makes me a little uncomfortable releasing an App into the wild when I potentially have an issue.

I'd like to get some feedback from someone that has gone through this a couple of times and can say "Yes, compiler issue" or "No, it's your code and you should fix it."

Thanks for any feedback.
 

Gary Milne

Active Member
Licensed User
Longtime User
Can you post the full error message?
There isn't much

** Activity (shot_recorder) Create, isFirst = false **
** Activity (shot_recorder) Resume **
An error occurred:
(Line: 169) Add_Left_Menu_Buttons_Scrolling(SR_Flags.Shot_Buttons_In_Use, pnlScrollLeft)
java.lang.NullPointerException

I looked at it a little further and found that SR_Flags.Shot_Buttons_In_Use was part of a Type which was not initialized. After adding the Initialize I no longer get the above error message but now it just exits after about the 3rd launch without any errors at all.
 
Upvote 0

Gary Milne

Active Member
Licensed User
Longtime User
That is correct. In Rapid debug mode it would generate the error. Since adding an Initialize to the Type is seems to be reduced but still happens occasionally, however it still exits frequently without generating any messages.

When I run the release version everything seems to work as expected. I can live with the sporadic crashing debug mode as long as I know that it is something to do with the compiler and not some latent issue with my code that will haunt me when I release it into the wild.

Thanks Erel.
 
Upvote 0

Gary Milne

Active Member
Licensed User
Longtime User
Thanks for the offer Erel. If it gets too bad I may take you up on that.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…