Debugging Android

This section provides an insight into the debugging of an Android application. The USB debugging in Android is also explained.

Android DDMS

DDMS stands for Dalvik Debug Monitor Server. For the interacting operation of our android device or virtual device and our android application program Eclipse allows a perspective. For opening this perspective we choose in the following way.

Select Window → Open Perspective → Other → DDMS

The perspective contains several Views and used as independently. It permits

  1. The application to place calls and send SMS to the device.
  2. The application to set the current geo position.
  3. To perform a performance trace of our application.

LogCat View

The LogCat view helps to see the log or including the System.out.print() statements.

LogCat View
LogCat View

 

 

File explorer

The files explorer helps to show the files on the Android simulator.

File View
File View

 

 

Shell

A shell is a program that obeys our keyboard input from the user and performs actions as directed by the user. The android emulator can access through the console. Open a shell, switch to your “android-sdk” installation directory into the folder “tools”. For starting the shell we use the following syntax.

Syntax: – adb shell

We can copy the file through the following command.

Syntax: – // Assume the gesture file exists on your Android device

adb pull /sdcard/gestures ~/test

// Now copy it back

adb push ~/test/gesture /sdcard/gestures2

The application data is saved in the directory called “/data/data/package_of_your_app”.

More devices are running we can issue commands to one individual device.

Eg: –

# Lists all devices
adb devices
#Result
List of devices attached
emulator-5554 attached
emulator-5555 attached
# Issue a command to a specific device
adb -s emulator-5554 shell

Uninstall an application through adb

For uninstall an android application through an android application through the shell we switch the data/app directory (cd/data/app) and then delete our android application. We can also uninstall the application through the shell adb with package name.

Syntax: – adb uninstall <packagename>

Emulator console through telnet

We can use telnet to connect adb to the device. This permits to simulate certain things like incoming call, change the network “stability”, set our current geocodes etc. for establishing the connection to our simulated device we use “telnet localhost 5554” and for exiting the console session we use the command “quit” “exit”.

Eg: – To change the power settings of our phone to receive an sms and to get an incoming call we use the following codes.

# connects to device
telnet localhost 5554
# set the power level
power status full
power status charging
# make a call to the device
gsm call 012041293123
# send a sms to the device
sms send 12345 Will be home soon
# set the geo location
geo fix 48 51

Deploy the Application on a real device

To turn on “USB Debugging” on our device in we select in the settings Applications > Development then enables USB debugging. We need to install the driver for our mobile phone and you should note that the android version we used to developing must be installed version on your phone.

To select your phone, select the “Run Configurations”, select “Manual” selection and select your device.

Android Device Chooser
Android Device Chooser