As most of the Android developers, I also use Android emulator to test my code. Once I have a bit of working code, I put it on my HTC Desire to get the actual feeling. So with these graph, I wrote couple of JS function along with JS handler, I deployed my first cut of the graph to my Android 1.6 emulator (API Level 4) and launched the application. Graph got plotted as expected. So far so good. I added couple of improvements, like enabling hovers, clicks, legends etc and then again tested on emulator. It gave expected results. So now it was time to deploy it on my HTC Desire. After deploying it, when I launched the application, I could just see the white screen of WebView and nothing else. No beautiful graphs. Checked LogCat, Eclipse console, everything was fine. No error/warning messages. I again tested the same on emulator and it was working like a charm.
After doing a lot of debugging with JavaScript code (let me confess, it was more of hit-and-try) I found that I declared couple of JS variables like
var x = 0,
var y = 1
Notice the comma after var x = 0 ? Ideally it should be semicolon but as all developers do silly mistakes, I also had slip of finger. This was not highlighted by the Eclipse HTML editor and it worked quite well on emulator. But when it came to actual phone, this was caught and it stopped everything. Liked that WebKit/WebView is very strict, but at the same time emulator behaved differently. Also there were no logs logged in LogCat. This behavior of emulator really scared me. I know it was a mistake on my part, but at least emulator should behave in same manner as actual software does. I sincerely hope that with new upcoming updates (may be with Gingerbread) this kind of issues are resolved and we can see the consistent behavior of emulator and phone software.
Cheers !!!
- Jay


No comments:
Post a Comment