Global Sources
EE Times-Asia
Stay in touch with EE Times Asia
EE Times-Asia > Embedded

Debug software apps for Android-based designs

Posted: 14 Jan 2015 ?? ?Print Version ?Bookmark and Share

Keywords:Android Debug Bridge? debugging? USB? TCP? Dalvik Debug Monitor Server?

Next you'll see how to get the list of PIDs that use a JDWP service, and then explore how to connect to the debugger JDB. The first step is to use the adb jdwp command, which lists the PIDs that implement JDWP, as shown here:

root@rajaram-pc:/home/rajaram# adb jdwp

Now connect JDB to the JDWP process using the adb forward command, as shown in the following snippet. Then you connect to JDB using jdb -attach localhost:port.

root@rajaram-pc:/home/rajaram# adb forward tcp:8000 jdwp:1384
root@rajaram-pc:/home/rajaram# jdb -attach localhost:8000
Set uncaught java.lang.Throwable
Set deferred uncaught java.lang.Throwable
Initializing jdb ...
> threads
Group system:
??? (java.lang.Thread)0xc141b1e358 FinalizerWatchdogDaemon
cond. waiting
??? (java.lang.Thread)0xc141b1e1a8 FinalizerDaem cond. waiting

Once you're connected with JDB, you can debug your application using the JDB commands.

Example 2: Backing Up Your Phone with ADB
Another key feature of ADB is the ability to back up your Android device to a host PC and then restore it on the device. This feature can be handy if you lose data from your Android device. The following command-line snippet lists the various adb backup options:

adb backup [-f ] [-apk|-noapk] [-shared|-noshared] [-all] [-system|nosystem][]
???write an archive of the device's data to .
??? If no -f option is supplied then the data is written
??? to "backup.ab" in the current directory.
??? (-apk|-noapk enable/disable backup of the .apks themselves
??? in the archive; the default is noapk.)
??? (-shared|-noshared enable/disable backup of the device's
??? shared storage / SD card contents; the default is noshared.)
??? (-all means to back up all installed applications)
??? (-system|-nosystem toggles whether -all automatically includes
??? system applications; the default is to include system apps)
??? (is the list of applications to be backed up. If
??? the -all or -shared flags are passed, then the package
??? list is optional. Applications explicitly given on the
??? command line will be included even if -nosystem would
??? ordinarily cause them to be omitted.)

The backup command provides an option to choose the type of data for backup or even ignore certain data. This backup mechanism requires user intervention on the Android device side, as it provides the user an option to set a password for the backup and allow or deny the backup process, as shown in figure 7.

Figure 7: User interface option in an Android device when the ABD backup command is executed.

About the author
Rajaram Regupathy works as Principal Software Engineer with Cypress Semiconductor. He has more than 15 years of professional experience in developing firmware and system software embedded products. He enjoys designing and developing new technology products from scratch. He has patents in embedded domain and is also a senior ACM member and Linux and open source enthusiast. He has published books on Linux USB stack programming and other open source articles.

Used with permission from Apress Media LLC, a division of Springer Science+Business Media.Publishing, Copyright 2014. This article was excerpted from Unboxing Android: A hands on approach with real world examples, by Rajaram Regupathy.

?First Page?Previous Page 1???2???3???4???5

Article Comments - Debug software apps for Android-base...
*? You can enter [0] more charecters.
*Verify code:


Visit Asia Webinars to learn about the latest in technology and get practical design tips.

Back to Top