Friday, 11 March 2011

Debugging Android apps - Basic steps

1. Turn on the Line numbers
The basic way to see where the bug is, is to check the line numbers. To turn on it on eclipse, you can do it in two ways.
1.1 Right click Immediately on the left of the code editor and mark the option "Show Line Numbers"
1.2 Go to Preferences -> General -> Editor -> Text Editors and mark the option "Show line numbers"

2. Find the problem
The next step is try to find where could be the problem. For this purpose, you can use both logcat or bugReport
2.1 LogCat
Basically the There is two way to get the content of logcat. One is directly from the eclipse IDE and another one is from the console. Since the console will shows you all the logs regarding the mobile phone and not just about your specific application, I recommend you to use the one which is integrated in eclipse.
2.1.1 Eclipse logcat: On eclipse select Windows -> show view -> Others... Then select Android -> LogCat. It will appear under the editor
2.1.2 console logcat: Open a console (or a terminal) and type:

adb -s <serialNumber> logcat

I haven't see any time on this way, so it is quite unuseful.

2.2 BugReport

To use bug report, type in the console (or terminal):

adb -s <serialNumber> bugreport

In this case, it will shows you all the information regarding the system, also all the information showed in logcat. It is very useful when logcat is not enough for you. I am going to talk about the structure of bugReport in the future.

3. Fix the problem

Since the problem could be very specific depending, there is not general guide to fix it. Normally, if you follow the logcat, you will find the line in your code which doesn't work. The points is eclipse already has solved lexical, syntactical and semantics problems, then the problem should be running problems.

About me

I am software engineer and I am working as Android Engineer in Dubizzle (Dubai)

I am very interested in the world of Smart phones because it represents a revolution which is changing the world. I am learning how to program with Android and few times ago, to program with iOS. My intention is have knowledge of both worlds and try to improve que quality of my programs by using the best of them.

About this blog

The purpose of this blog is record all the technic information about all the projects that I have been part, which could be useful in the future. If you have some problem with them, just put some comment.