*
The moose likes Android and the fly likes How to debug an Android web app Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "How to debug an Android web app" Watch "How to debug an Android web app" New topic
Author

How to debug an Android web app

Daniel Trebbien
Ranch Hand

Joined: Jul 10, 2007
Posts: 44
Recently I was experimenting with PhoneGap and the Google Maps Javascript API V3 with the goal of writing a simple web app for Android that incorporates mapping. I quickly learned that unlike web development for web browsers, any errors including syntax errors in my code were silent failures; not even the Android log indicated that a JS error occurred!

When using Firefox there is the wonderful Firebug add-on which allows for easy debugging of web apps running in Firefox. Similar tools exist for other browsers.

Is there a Firebug-like tool for Android's WebView? If not, how do you debug an Android web app?
robi sen
author
Ranch Hand

Joined: Jan 25, 2011
Posts: 33
There are some tools and I will look for them for you because I do not remember them off the top of my head but I want to correct one point. You can use the ADB to find Javascript errors using logcat filters like

adb logcat browser

This will show you browser errors.
Daniel Trebbien
Ranch Hand

Joined: Jul 10, 2007
Posts: 44
robi sen wrote:There are some tools and I will look for them for you because I do not remember them off the top of my head but I want to correct one point. You can use the ADB to find Javascript errors using logcat filters like

adb logcat browser

This will show you browser errors.


I just checked and you are correct. I must have missed the error message the first time.

Hopefully there is an easier way to debug an Android web app.
Sebastien Blanc
author
Ranch Hand

Joined: Nov 18, 2004
Posts: 33
There is a Appendix in the book called "Debugging javascript" ;-)
The idea is to use the Web tools that is included in Chrome Desktop. And because Mobile Chrome is heavily based on the regular Chrome you can test your mobile app with the regular Chrome. Offcourse, it is not a 100% reliable method and besides that you should add logging and track these with ADB (and where you also can track regular javascript errors)


Sebastien Blanc
Pro Android Web Apps: Developing HTML5, JavaScript, CSS, and Chrome OS Web Apps
Daniel Trebbien
Ranch Hand

Joined: Jul 10, 2007
Posts: 44
Sebastien Blanc wrote:There is a Appendix in the book called "Debugging javascript" ;-)
The idea is to use the Web tools that is included in Chrome Desktop. And because Mobile Chrome is heavily based on the regular Chrome you can test your mobile app with the regular Chrome. Offcourse, it is not a 100% reliable method and besides that you should add logging and track these with ADB (and where you also can track regular javascript errors)


Interesting. It's approximately what I ended up doing. Only, I used Firefox and Firebug with a slightly-modified version of my Google Maps JS code.

In the "Debugging Javascript" appendix, do you mention other techniques besides using desktop Chrome?
Sebastien Blanc
author
Ranch Hand

Joined: Nov 18, 2004
Posts: 33
No it's mainly centered around chrome's developer tools but also present JSLint a code quality tool for your JS scripts.
 
wood burning stoves
 
subject: How to debug an Android web app