简体   繁体   English

Google Play服务库更新和缺少符号@ integer / google_play_services_version

[英]Google Play Services Library update and missing symbol @integer/google_play_services_version

When upgrading my project to the latest version of Google Play Services ( v4.0, released on Halloween 2013 ), you are now supposed to add a new tag into the AndroidManifest.xml file. 现在,将我的项目升级到最新版本的Google Play服务( v4.0,于2013年万圣节前发布 )时,现在应该在AndroidManifest.xml文件中添加一个新标签。

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

Unfortunately, when I try doing that, I then get this compile error: 不幸的是,当我尝试这样做时,我得到了这个编译错误:

android-apt-compiler: /blahblah/AndroidManifest.xml:409: error: Error: No resource found that matches the given name (at 'value' with value '@integer/google_play_services_version').

I can then navigate to the file at google-play-services_lib/res/values/version.xml and view the raw integer for that symbol: 然后,我可以导航到google-play-services_lib/res/values/version.xml的文件,并查看该符号的原始整数:

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

And then insert it back into my AndroidManifest.xml : 然后将其重新插入我的AndroidManifest.xml

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

Doing this works absolutely fine and I can then compile and run the project and app just fine. 这样做绝对可以,然后我就可以编译并运行项目和应用程序了。 But it's definitely an undesirable fix with obvious upgradability issues. 但这绝对是不受欢迎的修复程序,具有明显的可升级性问题。

Any ideas? 有任何想法吗?

For everyone using Eclipse, this is how you should do it. 对于每个使用Eclipse的人,这就是您应该这样做的方式。

Eclipse -> import -> existing android code -> browse -> navigate to google-play-services_lib FOLDER (android-sdk/extras/google/google_play_services/libproject). Eclipse->导入->现有的android代码->浏览->导航至google-play-services_lib文件夹(android-sdk / extras / google / google_play_services / libproject)。

Then, on your project 然后,在您的项目中

control click -> properties -> android -> libraries, add -> select the project you just imported -> ok 控制单击->属性-> android->库,添加->选择刚导入的项目->确定

Please note that this fix may only apply to IntelliJ users!! 请注意,此修复程序仅适用于IntelliJ用户! (More information at the bottom of this post that should apply to everyone.) (本文底部的更多信息应适用于所有人。)

Fixed this problem! 解决了这个问题! I use IntelliJ and it turns out I just had misconfigured the way I was including the google-play-services_lib module as a dependency. 我使用的是IntelliJ ,事实证明我只是错误地配置了将google-play-services_lib模块作为依赖项的方式。

As I fixed this entirely through GUI and not at all by editing any files, here's a couple of screenshots: 当我完全通过GUI而不是通过编辑任何文件来完全解决此问题时,以下是两个屏幕截图:

步骤1-初始项目结构 So my Project Structure started off looking like this... 所以我的项目结构开始看起来像这样...

第2步-删除了google-play-services库 Then I removed the google-play-services library from my dependencies list by selecting it and then clicking the minus button at the bottom. 然后,我将google-play-services库从依赖列表中删除,方法是选择它,然后单击底部的减号。 Notice the error at the bottom of the dialog, as my project absolutely does require this library. 请注意对话框底部的错误,因为我的项目确实确实需要此库。 But don't worry, we'll re-add it soon! 但是请放心,我们会尽快重新添加!

步骤3-将google-play-services添加为模块依赖项 Next I added google-play-services_lib as a module dependency instead of a library dependency. 接下来,我将google-play-services_lib添加为模块依赖关系,而不是库依赖关系。 Then I hit the up arrow button at the bottom a couple times to move this dependency to the top of the list. 然后,我几次点击底部的向上箭头按钮,以将此依赖项移至列表的顶部。 But notice the error at the bottom (we're still not done yet!) 但是请注意底部的错误(我们尚未完成!)

步骤4-点击灯泡,将google-play-services库添加为依赖项 I then clicked the lightbulb at the bottom of the dialog in the error message area to bring up this little small popup that gives two choices ( Add to dependencies... or Remove Library ). 然后,我在错误消息区域的对话框底部单击了灯泡,以弹出这个小小的弹出窗口,该弹出窗口提供了两种选择(“ 添加到依赖项”或“ 删除库” )。 Click the Add to dependencies... option! 单击添加到依赖项...选项!

第5步-将库添加到google-play-services_lib模块 A new small dialog window should have popped up. 应该会弹出一个新的小对话框窗口。 It gave me two choices, one for my main project (it's name is blurred out), and then another for the google-play-services_lib project. 它给了我两个选择,一个用于我的主项目(名称模糊),另一个用于google-play-services_lib项目。 Yours may have a bunch more depending on your project (like you may see actionbarsherlock , stuff like that). 您的项目可能还有更多,具体取决于您的项目(例如您可能会看到actionbarsherlock东西)。 Select google-play-services_lib and click okay! 选择google-play-services_lib ,然后单击确定!

And finally, you're done! 最后,您完成了! I hope this helps someone else out there! 我希望这可以帮助其他人!

Further info 进一步的信息

I believe the reason that this issue was happening to begin with is because I thought that I had properly included the entire google-play-services_lib project into my overall project... but I actually had not, and had instead only properly included its jar file ( google-play-services_lib/libs/google-play-services.jar ). 我相信这个问题刚开始的原因是因为我认为我已经将整个google-play-services_lib项目正确地包含到了我的整个项目中...但是我实际上没有,而是只正确地包含了它的jar文件( google-play-services_lib/libs/google-play-services.jar )。 That jar file only includes code, not Android resources values, and so as such the @integer/google_play_services_version value was never really in my project. 该jar文件仅包含代码,不包含Android资源值,因此@integer/google_play_services_version实际上不在我的项目中。 But the code was able to be used in my project, and so that made it seem like everything was fine. 但是代码可以在我的项目中使用,因此看起来一切都很好。

And as a side note, fixing this issue also seems to have fixed the GooglePlayServicesUtil.getErrorDialog(...).show() crash that I used to have. 另外,解决此问题似乎还解决了我以前遇到的GooglePlayServicesUtil.getErrorDialog(...).show()崩溃。 But that could also have been fixed by the update, not really 100% sure there. 但这也可以通过更新来解决,但并不是100%肯定在那里。

I faced the same issue, and apparently Eclipse somehow left the version.xml file in /res/values from the original google-play-services_lib project while making a copy. 我遇到了同样的问题,显然,Eclipse在复制时以某种方式将version.xml文件从原始google-play-services_lib项目中的/ res / values version.xml留了下来。 I pulled the file from original project and pasted it in my copy of the project and the problem is fixed. 我从原始项目中提取了文件并将其粘贴到我的项目副本中,此问题已得到解决。

On Eclipse, after importing the google play library to the project workspace I just copied the version.xml file from 在Eclipse上,将google play库导入到项目工作区后,我只是从复制了version.xml文件

google-play-services_lib/res/values/version.xml

to

MyProjectName/res/values/version.xml

对于使用gradle的任何人:不要包括项目源,而是使用SDK Manager下载它,并将此行添加到依赖项中:

compile 'com.google.android.gms:play-services:4.0.30'
  1. Install "Google Play Services" and "Google Repository" from Android SDK Manager. 从Android SDK Manager安装“ Google Play服务”和“ Google存储库”。
  2. Add the line compile 'com.google.android.gms:play-services:4.1.32@aar' to your build.gradle . compile 'com.google.android.gms:play-services:4.1.32@aar'compile 'com.google.android.gms:play-services:4.1.32@aar'build.gradle
  3. As result the resource @integer/google_play_services_version will be available. 结果,资源@integer/google_play_services_version将可用。

Off the cuff, it feels like your project is connected to an older version of the Play Services library project. 袖手旁观,感觉您的项目已连接到旧版本的Play Services库项目。 The recommended approach, by Google, is for you to find the library project in the SDK and make a local copy. Google推荐的方法是,您可以在SDK中找到库项目并进行本地复制。 This does mean, though, that any time you update the Play Services library project through the SDK Manager, you also need to replace your copy with a fresh copy. 不过,这确实意味着,每次通过SDK Manager更新Play Services库项目时,您还需要用新副本替换副本。

I also ran across this while trying to use google_play_services_froyo. 在尝试使用google_play_services_froyo时,我也遇到了这个问题。

I filed this bug: https://code.google.com/p/google-plus-platform/issues/detail?id=734 我提交了这个错误: https : //code.google.com/p/google-plus-platform/issues/detail?id=734

after the update to the last versión i had this problem with all my projects, but it was solved just adding again the library reference: 更新到最后一个版本后,我所有的项目都遇到了这个问题,但是解决了,只需再次添加库引用即可:

if you don´t have the library into your workspace in Eclipse you can add it with: File -> Import -> Existing Android Code Into Workspace -> browse and navigate to google-play-services_lib project lib, ( android-sdk/extras/google/google_play_services/libproject ). 如果您没有将该库放入Eclipse中的工作区,则可以使用以下方法添加该库: File -> Import -> Existing Android Code Into Workspace ->浏览并导航至google-play-services_lib项目lib,( android-sdk/extras/google/google_play_services/libproject )。

在此处输入图片说明

then deleting /bin and /gen folders of my project (something similar to the clean option) and building my project again. 然后删除我项目的/bin/gen文件夹(类似于clean选项)并再次构建我的项目。

Solved for Eclipse 为Eclipse解决

Follow the subsequent steps: 请执行以下步骤:

  1. Import the google-play-services_lib folder as project, using import->Existing Android Code Into Workspace 使用import-> Existing Android Code Into Workspace将google-play-services_lib文件夹作为项目导入
  2. From the project properties select Android section, on the bottom In the Library section click Add and select the google-play-services_lib and Apply Follow the link http://i.stack.imgur.com/opSeJ.png to see the screenshot 从项目属性中,选择“ Android”部分,在“库”部分的底部,单击“添加”,然后选择google-play-services_lib,然后单击“应用”。单击链接http://i.stack.imgur.com/opSeJ.png来查看屏幕截图

Google's Android Developer site has instructions on how to "Add Google Play Services to Your Project", and they are also relevant to how to upgrade the Play Services version. Google的Android开发者网站上提供了有关如何“将Google Play服务添加到您的项目”的说明,并且还与如何升级Play服务版本有关。 There is even a drop down menu to view instructions for either Eclipse, Android Studio, or "Something else". 甚至还有一个下拉菜单,可查看Eclipse,Android Studio或“其他”的说明。 That would be the best place to view instructions in case they change. 如果它们发生变化,那将是查看说明的最佳位置。 The page is here: 页面在这里:

http://developer.android.com/google/play-services/setup.html http://developer.android.com/google/play-services/setup.html

But since most of the answers here are for Eclipse, here is a brief summary for upgrading Play Services with Android Studio 但是,由于这里的大多数答案都是针对Eclipse的,因此这里是使用Android Studio升级Play服务的简短摘要

  1. Open the build.gradle file inside your application module directory. 打开应用程序模块目录中的build.gradle文件。 Note: Android Studio projects contain a top-level build.gradle file and a build.gradle file for each module. 注意:Android Studio项目包含每个模块的顶级build.gradle文件和build.gradle文件。 Be sure to edit the file for your application module. 确保为您的应用程序模块编辑文件。
  2. Update the build rule under "dependencies" to refer the version of play-services that you have downloaded on your development machine. 更新“依赖项”下的构建规则,以引用您已下载到开发计算机上的播放服务的版本。

You can find the version number for the version of play-services that you have downloaded on your development machine by looking in your \\sdk\\extras\\google\\m2repository\\com\\google\\android\\gms\\play-services folder, as explained here: How do I match a Google Play Services revision with an install version? 您可以通过在\\ sdk \\ extras \\ google \\ m2repository \\ com \\ google \\ android \\ gms \\ play-services文件夹中查找,来找到在开发计算机上下载的播放服务版本的版本号,如此处所述: 如何使Google Play服务修订版与安装版本匹配?

For Eclipse, I just added project reference to the google-play-services_lib in: 对于Eclipse,我刚刚在以下位置将项目引用添加到google-play-services_lib:

Properties-Android In the Library pane (bottom pane), ensure that the google-play-services_lib is listed. Properties-Android在“库”窗格(底部窗格)中,确保列出了google-play-services_lib。 If not, click the Add.. button and select google-play-services_lib. 如果没有,请单击“添加..”按钮,然后选择“ google-play-services_lib”。

I had same issue, the version.xml file was not in google-play-services_lib. 我遇到了同样的问题,version.xml文件不在google-play-services_lib中。 Just start you sdk manager and accept the update especially the things related to "extras". 只需启动您的sdk管理员,并接受更新,尤其是与“ extras”相关的内容即可。

While importing the google-play-services_lib, check the version code defined in AndroidManifest.xml and version.xml. 导入google-play-services_lib时,请检查AndroidManifest.xml和version.xml中定义的版本代码。 I had found the difference in version code and change it to 4242000 . 我发现版本代码有所不同,并将其更改为4242000 After making the change there is no more compilation error in @integer/google_play_services_version . 进行更改后, @ integer / google_play_services_version中不再有编译错误。 在此处输入图片说明

Fixed by adding Google Play Services to my Module:app gradle build file. 通过将Google Play服务添加到我的Module:app gradle构建文件中进行了修复。 Documentation also says to update version when you update GMS. 文档还说要在更新GMS时更新版本。

dependencies {

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

} 

Below are the main actions which will avoid a lot of errors when using Google play service Lib: 以下是在使用Google Play服务Lib时可以避免很多错误的主要操作:

  1. Make sure to copy the lib project to the Eclipse projects workspace. 确保将lib项目复制到Eclipse项目工作区。
  2. Target SDK for Google play service lib project should be "Google Google Play服务库项目的目标SDK应为“ Google
  3. API" 3- Meta data should be added to manifest file. API” 3-元数据应添加到清单文件中。
  4. Your project target SDK should be 17 unless you've completely updated to 19, because in some cases 19 not working well. 除非您已完全更新为19,否则项目目标SDK应该为17,因为在某些情况下19不能很好地工作。

I had the same issue with a project using Maven and IntelliJ. 使用Maven和IntelliJ的项目遇到相同的问题。 Google Play services are added as a maven dependency. Google Play服务被添加为Maven依赖项。 The maven build worked fine from command line, but IntelliJ complained about this missing symbol @integer/google_play_services_version Maven构建可以从命令行正常运行,但是IntelliJ抱怨此缺少的符号@integer/google_play_services_version

In my case I forced an update of the maven POM files and it solved the problem. 以我为例,我强制更新了Maven POM文件 ,它解决了问题。

In my case, I needed to copy the google-play-services_lib FOLDER in the same DRIVE of the source codes of my apps 就我而言,我需要将google-play-services_lib FOLDER复制到应用程序源代码的同一驱动器中

  • F:\\Products\\Android\\APP*.java <- My Apps are here so I copied to folder below F:\\ Products \\ Android \\ APP * .java <-我的应用程序在这里,所以我复制到下面的文件夹
  • F:\\Products\\Android\\libs\\google-play-services_lib F:\\ Products \\ Android \\ libs \\ google-play-services_lib

When not using an IDE, but using command line builds (using ant and ndk-build), this is how to solve it: 当不使用IDE而是使用命令行构建(使用ant和ndk-build)时,这是解决方法:

Install all the req'd parts with 'android' command. 使用“ android”命令安装所有必需的零件。 Then have a copy of google-play-service_lib/ in your project root. 然后在您的项目根目录中拥有google-play-service_lib /的副本。 Edit project.properties to include this line: 编辑project.properties以包括以下行:

android.library.reference.1=./google-play-services_lib

I had the same issue. 我遇到过同样的问题。 The issue was that the "google-play-services.jar" was not properly imported into my project even though it was part of the google_play_service_lib project. 问题是即使“ google-play-services.jar”是 google_play_service_lib项目的一部分, 也没有正确导入到我的项目中。 If you are using Eclipse, please check and see if you can see the play services jar file in the Android Private Libraries section and if this is exported by the library. 如果您使用的是Eclipse,请检查并查看Android私有库部分中的play services jar文件,以及该文件是否由库导出。

I am using Android SDK platform tools version 17 (not 19) and Android SDK tools version 22.0.1 我正在使用Android SDK平台工具版本17(而非19)和Android SDK工具版本22.0.1

我刚刚更新了Android SDK Manager中Extras文件夹下的Google Play服务

Google suggests you don't create a project directly from the SDK directory. Google建议您不要直接从SDK目录创建项目。 It's better to copy the lib project out to the location where your app is, then import it from there. 最好将lib项目复制到应用程序所在的位置,然后从那里导入它。 Otherwise the next time you go to import the project for another app, it will already be in use. 否则,下一次您为另一个应用程序导入项目时,该项目将已经被使用。

https://developer.android.com/google/play-services/setup.html https://developer.android.com/google/play-services/setup.html

Note: You should be referencing a copy of the library that you copied to your development workspace—you should not reference the library directly from the Android SDK directory. 注意:您应该引用复制到开发工作区的库的副本—您不应直接从Android SDK目录中引用该库。

The problem for me was that the library project and the project using play services were in different directories. 对我来说,问题在于图书馆项目和使用播放服务的项目位于不同的目录中。 So just: 所以就:

  • 1.Add the files to the same workspace then remove the library. 1.将文件添加到同一工作空间,然后删除库。
  • 2.Restart eclipse 2,重启日食
  • 3.Add the library project again 3.再次添加库项目
  • 4.Clear 4.清除

展望2017年的任何人,Play服务的10.0.1版本都需要导入play-services-basement (以前在play-services-base )。

Android Studio 3.3.2 under Windows 10 Windows 10下的Android Studio 3.3.2

File -> Invalidate Caches/Restart and choose invalidate and Restart button in the dialog appeared. File-> Invalidate Caches / Restartinvalidate and Restart在对话框中选择invalidate and Restart按钮。

I had the same problem, add this 2 line in your build.gradle the problem will be resolved probably. 我有同样的问题,请在您的build.gradle中添加这2行,可能会解决该问题。 ;) ;)

dependencies {  
  implementation 'com.google.android.gms:play-services:12.0.1'  
  implementation 'com.google.android.gms:play-services-vision:10.0.0'    
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 对于intellij,无法解析符号@ integer / google_play_services_version - Cannot resolve symbol @integer/google_play_services_version for intellij 错误:找不到资源整数/ google_play_services_version(又名app:integer / google_play_services_version) - error: resource integer/google_play_services_version (aka app:integer/google_play_services_version) not found 找不到Android清单@ integer / google_play_services_version - Android manifest @integer/google_play_services_version not found Android Studio AdMob错误无法解析符号@ integer / google_play_services_version“/&gt; - Android Studio AdMob error cannot resolve symbol @integer/google_play_services_version"/> Android:找不到Admob资源@ integer / google_play_services_version - Android: Admob resource not found @integer/google_play_services_version 来自aar库的google_play_services_version值出错 - Error with google_play_services_version value from aar library 找不到google_play_services_version - google_play_services_version not found 未找到与给定名称匹配的资源(值与值 @integer/google_play_services_version)”- Visual Studio 2015 更新 3 - No resource found that matches the given name (at value with value @integer/google_play_services_version)” - Visual Studio 2015 Update 3 如何修复“找不到与给定名称匹配的资源(&#39;value&#39;与值&#39;@ integer / google_play_services_version&#39;)” - How to fix “No resource found that matches the given name (at 'value' with value '@integer/google_play_services_version')” google_play_services_version)。 错误:处理失败 - google_play_services_version) not found. error: failed process
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM