Android – Enable Debug on Android Phone

Sometimes, the application performance on phone is different from emulator. Just like the WatchFootballApp, we found that it takes more time on refreshing the results on device.

Adding debug message and debug your phone in DDMS is useful for locating the bottleneck of the application performance. Please refer to Android – Capture Screenshot to enable the USB Debug on your Android phone.

First of all, we have to add the debug message on the Java class which we would like to look into. To add a debug message, simply use the android.util.Log.

import android.util.Log;

...
Log.v("tag", "message"); // Log level: Verbose
Log.d("tag", "message"); // Log level: Debug
Log.i("tag", "message"); // Log level: Info
Log.w("tag", "message"); // Log level: Warn
Log.e("tag", "message"); // Log level: Error

As shown in the above code snippet, the log is divided into 5 levels and the tag is for better readability of Logcat in DDMS.

For example, i add the following logs in a method and i monitor the application using the DDMS perspective in Eclipse.

Log.v("kit", "*** 1 ***");
...
Log.v("kit", "*** 2 ***");
...
Log.v("kit", "*** 3 ***");
...
...
Log.v("kit", "*** 7 ***");

And this is what i got in the Logcat View. You can filter different log level by pressing the color button.

In addition, there is a filter field at the bottom such that i can display my log easily and now i know that the code between log 1 and 2 is the performance bottleneck.

 

Remember to turn off the debug mode of your phone and unmount the SD card before detached your phone from the computer. By the way, u can also capture the screenshot on your phone using the DDMS perspective in Eclipse.

Done =)

8 thoughts on “Android – Enable Debug on Android Phone”

  1. Do you know how to enable java Logs on Zoom2 board..??
    the normal sop/log.v,log.d will work only for emulator..!
    How about taking the loggs on Zoom2 board

    Like

  2. what kind of debugging is this?
    its just printing a predefined string on catlog.
    is there any way I can see runtime values of the expressions?

    Like

    1. Hi Usman,

      u can run the application in the debug perspective in eclipse. but i guess this only works when running the application in the emulator.

      Kit

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.