What is the best way to support both android map apis in my application ?
Google released the android google map api v2 while the v1 is still around (and works better for older phones).
So far, I see two scenarii.
1) Two apks : one apk for each api
I could use the multiple apk feature available in google play.
- How would I do the distinction on
google play? On the opengl support ?
This scenario means that each time I want to build my project, I have to copy/paste some files, update others which could be cumbersome.
Unless I use a tailored build process (Using ant or maven).
- Any recommendation on that matter ?
2) One apk
That one could be achieved using if/else statements, including in the manifest file the declaration for both the apis.
- Has anyone ever tried this ?
Note : Google maps for older phones
First, the new v2 api is vector based which is heavier on the CPU/GPU (the v1 api used bitmap tiles).
Second, the new v2 api requires opengl 2.0. Which is said to be supported in all Android device running froyo or later.
Unfortunately, this is not true.
For example, a venerable HTC magic running gingerbread (on a custom rom) is not recognized by the google play/market to support opengl 2.0.
And maybe there are more of them…
Well, you cannot have “if/else statements” in the manifest.
There are basically three scenarios from my standpoint:
As you note in your comment on another answer, my Scenario #1 cannot co-exist with the other two, simply because you must have the
<uses-feature>element calling for OpenGL ES 2.0. And, since the Play Store does not support multiple APK files based on OpenGL ES API level, you cannot support Scenario #1 and the other two scenarios at the same time for the same Play Store listing. You would have to have two completely separate apps in the Play Store: one that only uses Maps V1 that works on all Android devices and one that uses Maps V2 (falling back to something else, like Maps V1, for my Scenario #2) that works on OpenGL ES 2.0+ devices.Also, bear in mind that Maps V1 API keys are not going to be available after 3 March 2013. Doing Maps V1 development after that point gets increasingly risky, as you have no way of getting fresh API keys should something go wrong with your development environment.
Basically, what this means is that developing apps dependent upon Google Maps sucks in new and interesting ways, compared to the way it sucked before. Even if you say that you will abandon Maps V1 outright, there are the devices that fall into my Scenario #2. Hopefully, there are not that many, though there definitely are some (such as an HTC EVO 3G sitting near me). There should be no such devices running Android 3.0 and higher — I’m pretty sure that OpenGL ES 2.0 was a hard-and-fast requirement for Android 3.0, and the Play Store should be on all of those devices (and, hence, Google Play Services should be available for all of them).
Frankly, the best answer for some developers will be to dump Google entirely with respect to maps and use OpenStreetMap or something else that has greater stability, if they want to support Android 1.x/2.x devices.