将Google Play服务版本添加到您应用的清单中?

时间:2013-11-09 17:28:19

标签: android google-maps-android-api-2 google-play-services

我正在关注本教程:https://developers.google.com/maps/documentation/android/start#overview 关于如何将Google地图添加到Android SDK中的应用程序。

我似乎遇到的唯一问题是在这一点上(我做了其他一切没有错误):

Edit your application's AndroidManifest.xml file, and add the following declaration within the

 <application> element. This embeds the version of Google Play services that the app was compiled with.

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

The error is:
   No resources found that match the given name (at 'value' with value '@integer/    
   google_play_services_version').

我试图按照这个人的解决方案解决同样的问题:Google Play Services Library update and missing symbol @integer/google_play_services_version

但我仍然遇到同样的错误。有什么帮助吗?

18 个答案:

答案 0 :(得分:99)

可能是您的图书馆没有正确链接到项目,或者您有较旧的google-play-services库版本,因此出现冲突并且Eclipse变得愚蠢..:S

不,您不需要在integers.xml中添加任何内容。当您正确地将Google-play-services库链接到您的项目时,将找到参考android:value="@integer/google_play_services_version",您就可以开始使用了。当您将库添加到项目中时,只需再做一个干净利落的Eclipse环境就可以正确地扫除事物了。

如果您在下一个播放版本出现时将此数字硬编码,则需要更新它。如果你忘记了,你会花时间再寻找bug ..:S

希望它有所帮助。 ;)

答案 1 :(得分:36)

我得到了解决方案。

  • 步骤1:在Package explorer(eclipse左侧)
  • 上右键单击您的项目
  • 第2步:转到Android。
  • 第3步:在库部分添加库...(google-play-services_lib)
    见下面的小巴

    • 复制
    • 上的图书馆项目

    <android-sdk>/extras/google/google_play_services/libproject/google-play-services_lib/

    • 到您维护Android应用项目的位置。 如果您使用的是Eclipse,请将库项目导入工作区。点击文件&gt;导入,选择Android&gt;将现有的Android代码导入Workspace,并浏览到库项目的副本以将其导入。
    • Click Here了解更多。
  • 第4步:点击Apply
  • 第5步:点击“确定”
  • 第6步:从包资源管理器中刷新您的应用程序。
  • 第7步:您将看到错误消失。

答案 2 :(得分:30)

来自here

  

您应该引用您复制到的库的副本   您的开发工作区 - 您不应该引用该库   直接来自Android SDK目录。

我遇到了这个错误,因为我引用了SDK目录中的原始副本。确保首先将库复制到android工作区并仅引用它。在eclipse中,你可以通过检查&#34;将项目复制到工作空间&#34;导入项目时。

答案 3 :(得分:22)

在Android Studio中,只需将其添加到Gradle文件即可解决此问题:

compile 'com.google.android.gms:play-services:6.5.87'

修改

现在,由于更新和新的Gradle API,您应该使用的行是:

implementation 'com.google.android.gms:play-services:12.0.0'

一个更重要的提示:避免使用捆绑版本的Google Play服务,但请考虑声明应用所需的依赖项,以减少其大小,并减少不必要的65k方法限制。像(比如地图)这样的东西比上面的一般游戏服务用法更好:

implementation 'com.google.android.gms:play-services-maps:12.0.0'

答案 4 :(得分:7)

只需添加图书馆参考,转到Propertes - &gt; Android,然后添加库。

enter image description here

然后加入AndroidManifest.xml

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

答案 5 :(得分:3)

我在Android Studio 1.2.1.1中遇到了同样的问题。这只是liske其他答案说,然而,我无法找到添加依赖项的位置。最后,我在文件 - &gt;项目结构 - &gt;依赖关系下找到了它 此菜单将为您提供添加依赖关系到Google Play服务库的选项。

答案 6 :(得分:2)

在我的情况下,我必须从SDK管理器安装google存储库。

答案 7 :(得分:2)

尝试按照本文档中的说明安装4.0.30:http://developer.android.com/google/play-services/setup.html

答案 8 :(得分:1)

我得到了同样的错误;我以前为谷歌地图安装了google-play-services_lib(它工作正常)但是当我后来尝试将元数据条目添加到我的Manifest时,我收到了错误。我尝试了上述所有建议但没有任何东西可以正确地联系起来我最终从我的项目中删除了链接(project-properties-Android,删除了google-play-services_lib库),然后从Eclipse工作区中删除,删除了磁盘上的文件,最后使用SDK管理器从头开始重新安装。

这似乎最终成功了;现在Eclipse决定允许我保留元数据条目而没有错误。

答案 9 :(得分:0)

您可以更改工作区而不是修复该问题,而不是将修复的项目导回到主工作区。此外,这4个步骤应该是为了希望将来帮助某人。

答案 10 :(得分:0)

当您下载新版Google Play服务但未安装最新版SDK时,也会发生此错误。多数民众赞成在我身上发生的事因此,正如其他人所提到的,如果您尝试导入Google Play服务然后打开控制台,您将看到编译错误。尝试安装所有最新的Android SDK,如果是这种情况,请重试。

答案 11 :(得分:0)

我按照以下步骤进行了恢复:

1)将google play服务作为项目导入到你的android sdk中。在我的系统中找到它 C:\ ADT-束 - 窗口x86_64-20140702 \ SDK \额外\谷歌\ google_play_services \ libproject \谷歌播放-services_lib

2)你的android应用程序 - &gt;属性 - &gt; android

在窗口中

2.1)点击项目构建目标中的Google API  2.2)在底部框架中添加google-play服务,然后单击确定

希望它明确说明该怎么做!!

感谢。

答案 12 :(得分:0)

使用适当的库版本代码替换版本代码将解决您的问题,如下所示:

 <integer name="google_play_services_version"> <versioncode> </integer>

答案 13 :(得分:0)

在我的情况下,我需要将google-play-services_lib文件夹复制到我的应用源代码的相同DRIVE中

  • F:\ Products \ Android \ APP * .java&lt; - 我的应用程序在这里,所以我复制到下面的文件夹
  • F:\产品\的Android \库\谷歌播放-services_lib

答案 14 :(得分:0)

只需从项目中删除google play服务库并再次从sdk->extras->google文件夹添加即可完美解决我的问题。

答案 15 :(得分:0)

对于我的情况,我只是重新启动我的Eclipse并且它可以工作。

我已经工作了两个星期而没有关闭它,我认为它变得混乱。

感谢Ewoks提出的建议!

答案 16 :(得分:-3)

可以直接用作

android:value="6587000"

取代

android:value="@integer/google_play_services_version"

干杯。

答案 17 :(得分:-36)

您需要将“integers.xml”文件添加到项目的“res / values”文件夹中。该文件的内容应为..

<resources>
    <integer name="google_play_services_version">4030500</integer>
</resources>