185

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.

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

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

And then insert it back into my 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?

1
  • have exactly the same problem right now - but could not find the integer. Nov 7, 2013 at 20:19

26 Answers 26

256

For everyone using Eclipse, this is how you should do it.

Eclipse -> import -> existing android code -> browse -> navigate to google-play-services_lib FOLDER (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

9
  • I've tried this (following instructions from that other question to locate the folder), but Eclipse says it cannot write the .project file in the indicated google-play-services_lib directory. Obviously, the immediate reason is that Eclipse cannot write in the Program Files directory, where the SDK is located, but the more concrete question would be why modifying the .project file (that apparently belongs to the SDK and thus should be "correct") is necessary in the first place. Feb 25, 2014 at 12:21
  • I have not seen this before so I do not know exactly how to fix it. That in mind, unless explicitly modified already, I do not think the error exists within the folder. It is possible it is simply out of date and needs to be re-downloaded (unlikely to be the issue as well but you never know).
    – PSchuette
    Feb 25, 2014 at 13:09
  • Did you experience this error when trying to add the library or when trying to import the project?
    – PSchuette
    Feb 25, 2014 at 13:10
  • Thanks- worked for me, on Eclipse. I thought I'd done it right, but re-did it and that fixed the compiler issue. Mar 22, 2014 at 1:15
  • 4
    The FOLDER you need to import is here: extras\google\google_play_services\libproject
    – Kamil Szot
    Apr 5, 2014 at 18:34
78

Please note that this fix may only apply to IntelliJ users!! (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.

As I fixed this entirely through GUI and not at all by editing any files, here's a couple of screenshots:

Step 1 - Initial Project Structure So my Project Structure started off looking like this...

Step 2 - Removed google-play-services library Then I removed the google-play-services library from my dependencies list by selecting it and then clicking the minus button at the bottom. 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!

Step 3 - Added google-play-services as a module dependency Next I added google-play-services_lib as a module dependency instead of a library dependency. 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!)

Step 4 - Click the lightbulb to add the google-play-services library as a dependency 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!

Step 5 - Add the library to the google-play-services_lib module 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. Yours may have a bunch more depending on your project (like you may see actionbarsherlock, stuff like that). Select google-play-services_lib and click okay!

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). 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. 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. But that could also have been fixed by the update, not really 100% sure there.

10
  • 2
    Not working for me. I don't have the "lightbulb at the bottom of the dialog in the error message area to bring up this little small popup that gives two choices" Nov 29, 2013 at 17:42
  • 2
    In your case I'd maybe try completely removing Google Play Services from your project and then re-importing. As this missing integer issue only happens if the Google Play Services is improperly imported in the first place, it may be a good idea to start from scratch. Dec 6, 2013 at 17:13
  • 1
    @Vadorequest you can also select the google-play-services-lib module and add the google-play-services.jar file as a module dependency (!to the google-play-services-lib module!)
    – Suau
    Feb 10, 2014 at 5:18
  • 2
    In addition to this answer (IntelliJ specific) you if you are planning to actually use the libraries methods/classes, you'll have to go to File > Project Structure > select google-play-services_lib module > Dependencies and check "Exported" for the google-play-services.jar
    – Suau
    Feb 10, 2014 at 6:09
  • 2
    Summary: add the libproject directory as a module and make it a dependency to your main project to get the integer value from the libproject directory
    – John61590
    Apr 21, 2014 at 23:09
31

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. I pulled the file from original project and pasted it in my copy of the project and the problem is fixed.

2
  • This was the solution that also fixed me, it's an incredible oversight by Google if you ask me. Dec 31, 2013 at 14:18
  • 1
    This fixed my problem. Why the eclipse import skipped this file? Any clue?
    – nizam.sp
    Mar 1, 2014 at 12:10
24

On Eclipse, after importing the google play library to the project workspace I just copied the version.xml file from

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

to

MyProjectName/res/values/version.xml
1
  • 3
    Doing this will work, but the problem is that it makes upgrading to a newer version of the Google Play Services library a little bit more annoying. You'll probably have to replace the version.xml file with every upgrade. Dec 6, 2013 at 17:15
20

To anyone using gradle: don't include the project source, but instead download it using SDK Manager and add this line to dependencies:

compile 'com.google.android.gms:play-services:4.0.30'
4
  • Only that it doesn't find it:Error:A problem occurred configuring project ':app'. > Could not resolve all dependencies for configuration ':app:_debugCompile'. > Could not find any version that matches com.google.android.gms:play-services:6.1.+. Searched in the following locations: jcenter.bintray.com/com/google/android/gms/play-services/… jcenter.bintray.com/com/google/android/gms/play-services
    – matteo
    Oct 10, 2014 at 22:24
  • file:/home/teo/Documents/programmi/android-studio-new/sdk/extras/android/m2repository/com/google/android/gms/play-services/maven-metadata.xml file:/home/teo/Documents/programmi/android-studio-new/sdk/extras/android/m2repository/com/google/android/gms/play-services/ Required by: xxxxxxx:app:unspecified
    – matteo
    Oct 10, 2014 at 22:25
  • The path where it looks for the library seems not to match the location where the sdk manager has actually downloaded it, but even after creating a symbolic link, the issue is not fixed. I guess I can't figure out what file or folder exactly it needs to find. Any idea?
    – matteo
    Oct 10, 2014 at 22:27
  • 1
    To see what versions you have: "ls -1 $ANDROID_HOME/extras/google/m2repository/com/google/android/gms/play-services". To get newer versions, run SDK manager and update the components you want. Don't mess with symlinks. Oct 13, 2014 at 18:20
12
  1. Install "Google Play Services" and "Google Repository" from Android SDK Manager.
  2. Add the line compile 'com.google.android.gms:play-services:4.1.32@aar' to your build.gradle.
  3. As result the resource @integer/google_play_services_version will be available.
2
  • 1
    I added this compile 'com.google.android.gms:play-services:4.4.52'
    – powder366
    Jun 23, 2014 at 15:54
  • this did it for me. No one published what the end result of the dependencies section in build.gradle looked like... that would have been helpful
    – petemyron
    Jul 23, 2014 at 7:29
10

Off the cuff, it feels like your project is connected to an older version of the Play Services library project. The recommended approach, by Google, is for you to find the library project in the SDK and make a local copy. 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.

1
  • Yes, I did integrate the library into my project by placing a copy of the files downloaded with the Android SDK Manager into my working directory. Also I did update the library to this new version by doing the very same thing (copied the files from the Android SDK directory and overwrote the existing ones in my project). Nov 7, 2013 at 22:52
7

I also ran across this while trying to use google_play_services_froyo.

I filed this bug: https://code.google.com/p/google-plus-platform/issues/detail?id=734

7

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

enter image description here

then deleting /bin and /gen folders of my project (something similar to the clean option) and building my project again.

1
  • but this makes the apk 5mb heavier
    – Siddharth
    Dec 30, 2015 at 6:22
6

Solved for Eclipse

Follow the subsequent steps:

  1. Import the google-play-services_lib folder as project, using import->Existing Android Code Into Workspace
  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
1
  • My google-play-services_lib was in F:\Android\sdk\extras\google\google_play_services\libproject\google-play-services_lib Jan 31, 2015 at 17:14
5

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. There is even a drop down menu to view instructions for either Eclipse, Android Studio, or "Something else". 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

But since most of the answers here are for Eclipse, here is a brief summary for upgrading Play Services with Android Studio

  1. Open the build.gradle file inside your application module directory. Note: Android Studio projects contain a top-level build.gradle file and a build.gradle file for each module. 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?

1
  • Finally a good, clear answer for Android beginners. This answer should be placed higher. Mar 13, 2018 at 18:50
4

For Eclipse, I just added project reference to the google-play-services_lib in:

Properties-Android In the Library pane (bottom pane), ensure that the google-play-services_lib is listed. If not, click the Add.. button and select google-play-services_lib.

3

I had same issue, the version.xml file was not in google-play-services_lib. Just start you sdk manager and accept the update especially the things related to "extras".

2

While importing the google-play-services_lib, check the version code defined in AndroidManifest.xml and version.xml. I had found the difference in version code and change it to 4242000. After making the change there is no more compilation error in @integer/google_play_services_version.enter image description here

1
  • 2
    This is not a good way of doing it. You will need to manually update every time you update Google Play Services.
    – PSchuette
    Aug 5, 2014 at 18:28
2

Fixed by adding Google Play Services to my Module:app gradle build file. Documentation also says to update version when you update GMS.

dependencies {

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

} 
1

Below are the main actions which will avoid a lot of errors when using Google play service Lib:

  1. Make sure to copy the lib project to the Eclipse projects workspace.
  2. Target SDK for Google play service lib project should be "Google
  3. API" 3- Meta data should be added to manifest file.
  4. Your project target SDK should be 17 unless you've completely updated to 19, because in some cases 19 not working well.
1

I had the same issue with a project using Maven and IntelliJ. Google Play services are added as a maven dependency. The maven build worked fine from command line, but IntelliJ complained about this missing symbol @integer/google_play_services_version

In my case I forced an update of the maven POM files and it solved the problem.

1

In my case, I needed to copy the google-play-services_lib FOLDER in the same DRIVE of the source codes of my apps

  • F:\Products\Android\APP*.java <- My Apps are here so I copied to folder below
  • F:\Products\Android\libs\google-play-services_lib
1

When not using an IDE, but using command line builds (using ant and ndk-build), this is how to solve it:

Install all the req'd parts with 'android' command. Then have a copy of google-play-service_lib/ in your project root. Edit project.properties to include this line:

android.library.reference.1=./google-play-services_lib
1
  • But you need android update project -p . -t android-22 on google-play-services_lib first. Equivalently, add <property name="android.library.reference.1" value="./google-play-services_lib"/> to your build.xml (I minimized my build.xml and ditched the .properties). Feb 14, 2016 at 21:14
1

Android Studio 3.3.2 under Windows 10

File -> Invalidate Caches/Restart and choose invalidate and Restart button in the dialog appeared.

0

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

I am using Android SDK platform tools version 17 (not 19) and Android SDK tools version 22.0.1

0

I just updated Google Play services under the Extras folder in Android SDK Manager

0

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.
  • 2.Restart eclipse
  • 3.Add the library project again
  • 4.Clear
0

Google suggests you don't create a project directly from the SDK directory. It's better to copy the lib project out to the location where your app is, then import it from there. 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

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.

0

Anybody looking in 2017, the 10.0.1 version of play services requires importing play-services-basement (use to be in play-services-base).

2
  • Could you please explain a bit more? How do I see current dependencies and how to add more? Aug 14, 2017 at 6:34
  • I did it all manually and by trial and error when I wrote this answer. Using gradle made things much easier.
    – goobliata
    Mar 12, 2018 at 12:08
0

I had the same problem, add this 2 line in your build.gradle the problem will be resolved probably. ;)

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.