android - google map api v2 和旧版本的 google play services lib

标签 android google-maps google-play

我打算在我的 android 应用程序中使用 map ,我应该使用 google play 服务。我在这里读了很多问答,比如 this .在提到的问题中,接受的答案建议使用旧版本的谷歌播放服务库,比如 Froyo 的那个。我下载了 google play services r10 并在我的应用程序中使用它,但出现错误。

如果我从 list 中排除这行代码:

<meta-data
    android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" />

并在我的设备中运行该应用程序(我设备中当前版本的 google playe 服务是 3.2.66 ),它会抛出错误:

java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value.  Expected 4030500 but found 0.  You must have the following declaration within the <application> element:     <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />

如果我将它包含在 android:value=4030500 中,应用程序会运行,但会提示我应该更新我的“google play 服务”。

那么我应该放什么 android:value 或者我的方式是否正确?

问候

最佳答案

I downloaded google play services r10 and used it in my app

以上说法是你出现问题的根本原因。如果你真的使用了 r10(甚至 r12),那么在删除之后

<meta-data
    android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" />

从您的 AndroidManifest 中,您不会收到此错误:

java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value.  Expected 4030500 but found 0.  You must have the following declaration within the <application> element:     <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />

此错误只是说,您已链接到 4.0.30 版的 Google Play 服务库。

所以解决方案是删除上面的 meta-data 并确保链接到以前的版本之一。

如果使用 gradle 或 maven,只需将依赖版本设置为 3.2.65。如果以旧方式开发,请在 Android SDK 管理器中为 Froyo 下载 Google Play 服务,将其从 sdk/extras/google/ 复制到您的工作目录,然后在您的项目首选项中选择该项目作为库依赖项目.

关于android - google map api v2 和旧版本的 google play services lib,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20019118/

相关文章:

java - 运行测试android应用程序时出现几个错误

javascript - map 标记未呈现 - Phonegap 中的 Google Maps Javascript API v3

php - 更新数据库中的谷歌地图纬度/经度

android - 限制特定设备销售应用程序?

android - 通过 USB 安装 Android 市场应用程序

Android LRUCache 检索

Android:绘制多条路径

java - 进行 HTTP 调用时显示以下堆栈跟踪

javascript - 谷歌距离计算器和自动完成

android - 更改签名 key ,保留包名