7

as I am getting more and more into Android PhoneGap app development, I can see more and more nuances and little details between built-in Android browsers throughout the versions. I searched for some official or fan document, which would deal with these browser version differences. But I can't find anything useful.

It's a lot frustrating, because you have to test everything on all versions of Android emulator and if app grows big, it's A LOT of work to test all the features in all versions.

Everyone is excited about HTML5, I was too, but only to the point when I moved to doing the real thing. I realized that there is so many problems when dealing with different versions of Android behaving sometimes a lot differently.

If anyone has some good resource to share, I would be very happy. Thanks

EDIT: Added example of different behaviour betweeen Android browser versions ( but there is many of them):

This works in Android browser in 1.6, 2.2, 2.3 and 2.3.3. But it failes (application crashes or stops JS execution) in Android 2.1:

Object.keys(var).length 
Frodik
  • 14,986
  • 23
  • 90
  • 141
  • This is where you love those automated unit tests you made and run on all browsers. – Raynos Jun 10 '11 at 11:47
  • @Raynos - I hear a little irony or sarcasm in your comment :-) Can you please be more specific what you actually mean and could you supply some real world examples ? – Frodik Jun 10 '11 at 11:48
  • 1
    I'm just saying cross browser testing is a lot easier if you use javascript unit testing and then set up an automated browser testing cluster. QUnit, Browserling, TestSwarm, Selenium. – Raynos Jun 10 '11 at 11:58

3 Answers3

2

You asked a pretty general question. The general purpose answer is that any sort of cross browser development (even cross versions of the same browser) requires that you develop a familiarity with what features are safe across the targeted browsers, which features are not safe across the targeted browsers and which ones must be used only with careful testing or feature detection with fallback.

While one wouldn't exactly expect the type of difference you saw with the one example you referenced, it is clear that that is a fairly new feature in ECMAScript and it's not consistently implemented across normal browsers so I would put it in the category where it is not safe to assume that it works on all versions of Android, even if you've seen it some versions of Android. That means to me that you should only use it if you've explicitly tested that it's reliable in all the browser versions you are targeting or devise a feature test and only use it when you know it's present and reliable or develop a safer work-around.

As I think has been mentioned previously, this thread has a bunch of proposed work-arounds for the specific issue you mentioned.

I am not aware of any detailed written material that would document in advance for you the details of the differences between different Android browser versions. Since it's open source, there are probably developer checkin notes and some level of release notes, but that will probably be like looking for a needle in a haystack and may not even contain what you want. It is rare for any developers to produce such detailed information. We don't generally get that level of detail from any of the existing desktop browsers or iOS browsers and, even if you were on the development team itself, you probably would only see part of this info. I don't think you're going to find official documentation that covers what you want.

You're going to have to learn to treat is as more of an unknown and learn what areas are "safe", what areas require extensive testing before using and what areas are just too risky. Even when doing that, you'll find Android bugs in some version that trip you up. That's just the nature of building on someone else's platform. At least the Android set of browsers are a much simpler target than trying to target all desktop browsers from IE6 to IE9, Firefox 3 to 5, Safari 3 to 5, Opera 9 to 11, Chrome 9 to 12, all Android, all iOS and use HTML5 when available which is what I'm working on.

Once you've been through this wringer a couple times, you will realize that if the newer language/library feature carries any risk, you shouldn't use it at all unless it's absolutely central to what you're trying to accomplish and then you will have to test the hell out of it. If it's something like getting the length of the associative array which is just a programmer's convenience, then it's probably simpler to stick with a work-around that is guaranteed to be safe and just not spend your time dealing with any browser-support risk.

Community
  • 1
  • 1
jfriend00
  • 683,504
  • 96
  • 985
  • 979
0

The only official documentation I am aware of is part of the Android developer documentation. If I were a betting man, I would bet that it only covers a subset of what you are seeking.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Well, I am aware of the document you linked. It's not helpful in any way, it just contains some basic guidelines, nothing specific to eac browser version - that is what I am trying to find and it is probably mission impossible. – Frodik Jun 10 '11 at 14:17
0

The general idea behind cross browser Javascript is inline feature testing (at least how I've come to accept it.) I don't know exactly what "features" you are specifically looking for but it's generally wise to test for the existence of a feature set then use it and have a fallback if that doesn't exist. (Even if the fallback is, "This site requires a browser that supports 'foo'")

Since you didn't give any examples, I'll pick on Ajax. It's always best to check for the existence of window.XMLHttpRequest, then act upon it. Of course, this is not performant if you are doing it for every instance of need so you could write a check procedure or a wrapper to accept your list of necessity let your wrapper cache/call the appropriate methods to perform that task.

Without examples of "features" that you are talking about being different from browser to browser though, it's hard to give any concrete advice on direction.

Andir
  • 2,063
  • 1
  • 15
  • 22
  • Well I am looking for some developer guide where would be written what features and behaviour can one expect from each Android browser version. But I will add in my question one typical example as there is many of such. – Frodik Jun 10 '11 at 15:13