Wednesday, December 14, 2011

Exception reporting in Android applications

I was surprised and delighted to discover that the Android Market infrastructure has a mechanism to capture and report program exceptions which occur on the mobile device.  I discovered this because my app had a bug, and this system told me exactly where it was.

When a crash happens in the Android java code, it appears that either the Dalvik JVM and/or some monitor program in the underlying linux operating system captures the stack trace, uploads it to Google, and presents it to the app developer on the Developer Dashboard.  (Click here to go to yours.)

Early last week, I was trolling for statistics when I spotted this on my Developer Dashboard.  It reported one error and one report.  Within a few days, it had jumped to five reports.  (disclaimer: some image fields grayed-out for privacy)



I clicked on the circled link, and the next page summarized the problem, class name, and method name.



I clicked on the 'NullPointerException' link and the next page showed the exact line number.   Very nice.




I debugged the problem.  That line in my source code was not expecting or handling a null input parameter.  So when it got called with null, the app died.  My bad.  But easy to fix.

After I fixed the problem and udated the app version at the Android Market, I went back to the error page and clicked the button to mark this as an 'old' problem.  This seems to have moved the problem lower in my view.



I hope all my code bugs are this easy to fix.  Good luck debugging yours.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.