Saturday, June 16, 2012

Debugging Android Application directly from Android Mobile

We develop the android application and 75% of the time test using android simulator and witness the application working perfectly all right. We are happy and deploy the application to our android mobile (same target platform) and test verify. 90 to 95% of the time we see the application working alright with the actual device but sometimes we face issues.

What do we do next…we check back the application in simulator atleast once following the same scenario and see if we are able to replicate the issue. We see that the application works just fine in the same scenario in case of the simulator.

OK what next…what are our options…Well we have different mechanism to troubleshoot and the popular amongst those are as follows:

1.       Write to the log and then work through the application in the device with the same scenario reproducing the issue and then pull the log from the device and identify and solve the issue.
Yes but this type of troubleshooting is less preferable if the owner of the mobile is our pocket!!! This type of troubleshooting is more suitable when the user of our application lives in remote location.

2.       From the eclipse studio start debugging the application directly from the android device.
This is one of the easiest way to quickly troubleshoot and fix if we are facing the issue only when executing the application in the android mobile.

Ok…but how…well here is how you do this…

1.       From the Eclipse studio, pull open the “Windows” menu and select “Android SDK Manager” to view the list of target platform, additional libraries and Devices installed and/or available.

2.       From this list, expand the “Extras” folder and make sure “Google USB Driver” is installed as shown below in the screenshot. If this is not installed, then check mark the “Google USB Driver” and get this installed. Note: If any updates are available to the packages already installed, then they are selected by default. It is upto us if we want those updates or not.


3.       On your phone, click Settings > Applications > Development and make sure USB Debugging is on.

4.       After installing the “Google USB Driver”, connect the device to the system using the USB cable. A window opens up and prompt about installing drivers. Wait for it to complete.

5.       Open the command prompt window and navigate to the “platform-tools” directory under android-sdk directory. In my case it was (D:\Program Files\Android\android-sdk-windows\platform-tools)

6.       Type “adb devices” in the command prompt and this will list the devices installed. From this list you should see a serial number (some sequence of digits) and this happens to be the serial number of your android mobile. If you see so, then you are set to go.

7.       Now, instead of following the regular way of executing/running the application, this time it will be different. Right click on your project and from the context menu select Run As > Run Configurations…

8.       From the “Run Configurations” window, click the “Target” tab and select the “Manual” option from the “Deployment Target Selection Mode” panel as shown below


9.       Now click the “Run” button from the “Run Configurations” window and you will be prompted with the “Android Device Chooser” window.

10.   From the “Android Device Chooser” window, select “Choose a running Android device” option and then select the serial number (this will match with the serial number that displayed in the command window) and click the “OK” button.

11.   This time the application (apk file) is loaded directly in the android mobile and you can follow the same mechanism to debug it (Setting breakpoints and so on)

Hope this helps troubleshooting your issue…

Happy Androiding…

No comments: