Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Debugging Tips

Often my programs simply crash. I can't see anything in the LogCat or otherwise useful information elsewhere to find out what's gone wrong. The only thing I see is some kind of exception. This is unacceptable and makes Android programming nearly impossible. I'm sure there must be some additional help to debugging, but after weeks of searching, nothing.

Does anyone have hints on how to find a bug in a program that simply crashes?

General question I know, but without an answer, I'm going to have to quit trying to develop apps for Android. I can't spend weeks of searching for every simple mistake.

like image 539
Mitch Avatar asked Jul 23 '10 01:07

Mitch


1 Answers

There's also the actual Eclipse debugger. If you just run the program with the debugger until it crashes, you may not see a particularly helpful stack trace. But if you add a breakpoint or two in the code that comes just before the crash, you can step through carefully and figure out what's going wrong.

Also, although I'm still pretty new to Android development, my experience is that most of the mysterious crashes in my code are essentially ClassCastExceptions. Look carefully for all the places where you're casting something from one class to another, and make sure you're not assuming something is of a type that it's actually not.

like image 52
Tyler Avatar answered Nov 02 '22 17:11

Tyler