Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to debug an Android web app

 
Daniel Trebbien
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 33
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
Daniel Trebbien
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 33
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No it's mainly centered around chrome's developer tools but also present JSLint a code quality tool for your JS scripts.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic