Monday, May 28, 2012

Setup Android Debug Bridge with real Android Device


In first step, we need to enable Android device to debug mode:
Setting->Application->Development->USB debug (check it)

Next step is to add device to "adb"  list, following below:
  1. Log in as root and create this file: /etc/udev/rules.d/51-android.rules. Use this format to add each vendor to the file:
    SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", MODE="0666", GROUP="plugdev"

    In this example, the vendor ID is for HTC. The MODE assignment specifies read/write permissions, and GROUP defines which Unix group owns the device node.
    Note: The rule syntax may vary slightly depending on your environment. Consult the udev documentation for your system as needed. For an overview of rule syntax, see this guide to writing udev rules.
  2. Now execute:
    chmod a+r /etc/udev/rules.d/51-android.rules 
Please refer to android dev. site for more details.

Thirdly, in any head portion of your andoird Java source, placing

import android.util.Log;

Then, in the beginning of any class you would like to debug, add a "TAG" which is a string MACRO using for declaring the type of debugging message.

public class TouchHandler implements ITouchhandler
{
    ...
    private static final String TAG = "Touch Info";
    ...
    ...
    ... 
}

Ok, in any target code, you can add something like:

Log.d(TAG, "PointerCount="+event.getPointerCount());

There are different classees of debugging message which android platform provided.
you can refer to this link:
http://developer.android.com/guide/developing/debugging/debugging-log.html

Finally, it the most important step is to open the "adb Locat" application for realtime debugging with "real" android device.

Goto android sdk path:

~/android-sdks/platform-tools/sudo ./adb logcat

Here we go!!

You can see the screen capture shown above, the touch pointer location and the detected touch pointer counts are display synchronously with your action on the real device.