Posted by: murrayhking | December 9, 2009

Debugging Javascript with Android

To have a look at the console.log() output and the javascript errors from the android emulator…

Start up the emulator.

In the
/android-sdk-linux/tools directory of the android sdk there is the Android Debug Bridge (adb)

run the ./adb device command to get a list of emulators currently running

murray@ubuntu:/opt/android-sdk-linux/tools$ ./adb devices
List of devices attached
emulator-5554    device
emulator-5556    device

Attach to a specific emulator use “-s emulator-portNumber”

To get all the log entries for the emulator.

murray@ubuntu:/opt/android-sdk-linux/tools$ ./adb -s emulator-5554 logcat
I/Gears-J-RadioProvider(  690): LAC: -1
I/Gears-J-RadioProvider(  690): MNC: 260
I/Gears-J-RadioProvider(  690): MCC: 310
I/Gears-J-RadioProvider(  690): home MNC: 260
I/Gears-J-RadioProvider(  690): home MCC: 310
I/Gears-J-RadioProvider(  690): Signal strength: 7
W/dalvikvm(  690): Warning: Landroid/webkit/gears/AndroidWifiDataProvider;.onUpdateAvailable (Ljava/util/List;J)V was already registered/resolved?
I/Gears-J-RadioProvider(  690): Carrier: Android
I/Gears-J-RadioProvider(  690): Network type: 2
D/dalvikvm(  690): GC freed 3612 objects / 376968 bytes in 144ms
I/Gears-J-RadioProvider(  690): AndroidRadioDataProvider shutdown.

To view only the javascript errors and console.log() output. Add a filter to that command.

murray@ubuntu:/opt/android-sdk-linux/tools$ ./adb -s emulator-5554 logcat   WebCore:V *:S
D/WebCore (  690): Console: latlog[1]325934.7273999545 line: 66 source:
D/WebCore (  690): Console: latlog[0]673661.464196884 line: 67 source:

For Android 2.0 sdk change the filter slightly

murray@ubuntu:/opt/android-sdk-linux/tools$ ./adb -s emulator-5554 logcat  browser:V *:S

The :V is for verbose

  • V — Verbose
  • D — Debug
  • I — Info
  • W — Warning
  • E — Error

See adb docs at



  1. Many thanks for this post, it will be helpful in the coming months as I work on my own development projects.

  2. […] creates using the logcat application. I first realised you could use this command when I saw this post on the Geo-Mobile […]

Leave a Reply

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

You are commenting using your 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


%d bloggers like this: