如何查找 Android Google Play 服务版本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21360391/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How To Find Android Google Play Services Version
提问by user3184786
I'm working on an android project which requires the use of google maps. I've been reading tutorials, and I have to add this to the AndroidManifest.xml file:
我正在开发一个需要使用谷歌地图的安卓项目。我一直在阅读教程,我必须将其添加到 AndroidManifest.xml 文件中:
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
The thing is, I don't know what number to substitute the "@integer/google_play_services_version" with.
问题是,我不知道用什么数字代替“@integer/google_play_services_version”。
If anyone knows what I should enter there, and how to obtain that integer value, I'd appreciate it.
如果有人知道我应该在那里输入什么,以及如何获得该整数值,我将不胜感激。
回答by Raghunandan
There is no need to subsitute. The value @integer/google_play_services_version
takes care of it. Just make sure you have the latest Google Play Services library which is updated.
没有必要替代。值@integer/google_play_services_version
会照顾它。只需确保您拥有更新的最新 Google Play 服务库。
You can find it under google-play-services_lib>res>values>version.xml
if you wish to add the number rather than @integer/google_play_services_version
.
google-play-services_lib>res>values>version.xml
如果您想添加数字而不是 ,您可以在下面找到它@integer/google_play_services_version
。
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="google_play_services_version">4030500</integer>
</resources>
回答by Sam003
Here is the official guide for setting up Google Play Servicesin your project.
这是在您的项目中设置 Google Play 服务的官方指南。
FYI,you could find the version number in this folder:
仅供参考,您可以在此文件夹中找到版本号:
~\android-studio\sdk\extras\google\m2repository\com\google\android\gms\play-services
Enjoy.
享受。
回答by Maryam
Error you have mentioned is maybe because of not adding Google play services lib as library of your project do the following.
您提到的错误可能是因为未将 Google Play 服务库添加为您的项目库,请执行以下操作。
- Select File -> Import -> Android -> Existing Android Code Into Workspace and click Next.
- Select Browse, enter /extras/google/google_play_services/libproject/google-play-services_lib, and click Open. 3.Select Copy projects into workspace and click Finish.
- 选择 File -> Import -> Android -> Existing Android Code Into Workspace,然后单击 Next。
- 选择浏览,输入 /extras/google/google_play_services/libproject/google-play-services_lib,然后单击打开。3.选择将项目复制到工作区并单击完成。
Mark Google Play services as a library: Right-click the google-play-services_lib project, and choose Properties > Android. Tick the Is Library option.
将 Google Play 服务标记为库:右键单击 google-play-services_lib 项目,然后选择“属性”>“Android”。勾选是库选项。
Right click on your project -> go to properties -> click android -> click add button -> click google_play_services_lib -> ok -> apply -> ok clean your project this will remove your error
右键单击您的项目 -> 转到属性 -> 单击 android -> 单击添加按钮 -> 单击 google_play_services_lib -> 确定 -> 应用 -> 确定清理您的项目,这将消除您的错误
回答by MikeL
If you are using gradlejust make sure you have the updated google play services version (downloaded using SDK manager) and put this in your project module dependency section:
如果您使用的是gradle,请确保您拥有更新的 google play 服务版本(使用 SDK 管理器下载)并将其放在您的项目模块依赖项部分:
compile 'com.google.android.gms:play-services:+'
IMPORTANT NOTE:
In general it is not a good practice to remove the concrete version of the source you are compiling against.
重要说明:
一般来说,删除您正在编译的源代码的具体版本并不是一个好习惯。
回答by Joe Plante
I was in a case where I had to use the Froyo version of the Google Play Services, and that version doesn't require the tag. In fact, the XML entry google_play_services_version does not exist in the Froyo+ version of the Google Play Services library
我曾经遇到过必须使用 Google Play 服务的 Froyo 版本的情况,而该版本不需要标签。实际上,Google Play Services 库的 Froyo+ 版本中并不存在 XML 条目 google_play_services_version
回答by Abhi
It is probably that your library is not linked to project properly or that you have older google-play-services library version so conflict appears and Eclipse got stupid.. :S
可能是您的库未正确链接到项目,或者您的 google-play-services 库版本较旧,因此出现冲突并且 Eclipse 变得愚蠢.. :S
No you don't need to add anything in integers.xml. When you link properly Google-play-services library to your project reference android:value="@integer/google_play_services_version" will be found and you are ready to go. When you add library to your project just do one more clean so funny Eclipse environment sweep-out things properly.
不,您不需要在 integers.xml 中添加任何内容。当您将 Google-play-services 库正确链接到您的项目参考时,将找到 android:value="@integer/google_play_services_version" 并且您已准备就绪。当您将库添加到您的项目时,只需再做一个更干净、如此有趣的 Eclipse 环境,即可正确地清除所有内容。
If you hardcode somewhere this number when next play version come you would need to update it. And if you forget that, you will spend time again looking for bug.. :S
如果您在下一个播放版本出现时将此数字硬编码在某个地方,则您需要更新它。如果您忘记了这一点,您将再次花时间寻找错误.. :S
Hope it helped. ;)
希望它有所帮助。;)