什么是同时支持谷歌地图的API(v1和v2)的最佳方法是什么? [英] What is the best way to support both google map apis (v1 and v2)?

查看:238
本文介绍了什么是同时支持谷歌地图的API(v1和v2)的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是同时支持Android的地图API的在我的应用程序的最佳方法是什么?

谷歌发布了Android谷歌地图API V2 第一版仍然存在(和旧手机工作得更好)。

到目前为止,我看到两个scenarii。

1)两个的apk:一是APK每个API

我可以使用多个APK功能,可以在谷歌播放

  • 我怎么会做的区别谷歌播放?在OpenGL的支持?

该方案意味着,我要建立我的项目每一次,我需要复制/粘贴一些文件,更新其他人可能很麻烦。

除非我用一个量身打造的过程(使用Ant或Maven)。

  • 在这个问题的任何建议?

2)一的apk

,人们可以使用实现的if / else 语句,包括清单文件中声明<强>双方的API。

  • 有没有人试过这种?

注:谷歌地图的旧手机

首先,新的V2 API是基于矢量的这是对CPU / GPU重(V1的API使用位图砖)。

二,新的第2版API需要OpenGL 2.0。据说这是在运行升级Froyo 或更高版本的所有Android设备被支持。 <一href="http://stackoverflow.com/questions/9771458/does-every-device-which-has-android-froyo-2-2api-8-supports-opengl-es-2-0">Unfortunately, 这是不正确

例如,一个令人尊敬的HTC Magic运行姜饼(一个自定义ROM)不是由谷歌播放/市场认可,以支持OpenGL 2.0。

也许还有更多的人......

解决方案
  

,人们可以使用实现if / else语句,包括在清单文件中声明这两个API的。

好了,你不能有if / else语句中的清单。

有从我的角度来看基本上有三种情况:

  1. 在该设备没有的OpenGL ES 2.0或更高版本
  2. 在该设备确实的OpenGL ES 2.0或更高版本,但没有presently有谷歌播放服务(可能是因为它没有Play商店)
  3. 在该设备具有的OpenGL ES 2.0或更高版本,并且谷歌播放服务

正如您注意:在对另一个回答您的意见,我的场景#1不能共存与其他两个,只是因为你的必须的已在&LT;使用特征&GT ; 元素要求的OpenGL ES 2.0。而且,由于Play商店不支持基于OpenGL ES API级别的多个APK文件,你不能支持方案1和其他两种方案在同一时间对同一Play商店上市。你就必须有两个完全独立的应用程序在Play商店:一个只使用地图V1在所有Android设备的作品和一个使用地图V2(回落到别的东西,如地图V1,为我的情景#2)适用于OpenGL ES的2.0 +设备。

另外,请记住,地图V1 API密钥不会之后,2013年3月3日可用。做旅游V1的发展后该点变得越来越危险的,因为你没有办法让新鲜的API密钥有某些问题与您的开发环境。

基本上,这是什么意思是,发展依赖于谷歌地图应用程序吸进新的和有趣的方式,相比之前它吸的方式。即使你说你会放弃地图V1顾左右而言他,还有落入我的情景2的设备。但愿,有没有那么多,但肯定有一些(如HTC EVO 3G坐在我旁边)。应该有运行Android 3.0和更高版本没有这样的设备 - 我是pretty的肯定的OpenGL ES 2.0是为Android 3.0的硬和快速的要求,Play商店应该是在所有这些设备(和,因此,谷歌播放业务应可用于所有的人)。

坦率地说,对于一些开发商最好的答案将是抛售谷歌完全相对于地图和使用OpenStreetMap的或具有更高的稳定性,如果他们想支持Android 1.x的/ 2.x设备别的东西。

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...

解决方案

That one could be achieved using if/else statements, including in the manifest file the declaration for both the apis.

Well, you cannot have "if/else statements" in the manifest.

There are basically three scenarios from my standpoint:

  1. The device does not have OpenGL ES 2.0 or higher
  2. The device does have OpenGL ES 2.0 or higher but does not presently have the Google Play Services (possibly because it does not have the Play Store)
  3. The device has OpenGL ES 2.0 or higher and has Google Play Services

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.

这篇关于什么是同时支持谷歌地图的API(v1和v2)的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆