90

I'm following this tutorial: https://developers.google.com/maps/documentation/android/start#overview on how to add Google Maps to an app within the Android SDK.

The only problem I seem to be having is during this bit (I've done everything else with no errors):

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

I've tried to follow this persons solution to the same problem: Google Play Services Library update and missing symbol @integer/google_play_services_version

but I'm still getting the same error. Any help please?

Community
  • 1
  • 1
Adz
  • 2,809
  • 10
  • 43
  • 61

18 Answers18

101

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

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.

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

Hope it helped. ;)

Ewoks
  • 12,285
  • 8
  • 58
  • 67
  • 1
    yep, on android studio I've added google play service as a module (not as a library), but I've forgot to add this module to my project module where the manifest file is. This solved the problem :) – Ragaisis Nov 30 '13 at 09:13
  • 18
    Thanks, this fixed my issue. For an idiot-proof step-by-step guide for referencing a library project in Eclipse / ADT, please see [the Google Tools docs](http://developer.android.com/tools/projects/projects-eclipse.html#ReferencingLibraryProject). I'm apparently an idiot, because I was trying to add the library under "Java Build Path : Libraries" - no worky. – Goffredo Dec 19 '13 at 02:38
  • Sorry for the late reply, but yes, this was the problem, the library wasn't linked properly to my project! – Adz Jan 11 '14 at 16:24
  • 1
    How to do that for Ant? – Dzmitry Lazerka Mar 10 '14 at 07:10
  • after adding via project, I get that the entire app cannot execute – user3241507 Apr 29 '14 at 07:13
  • Thanks Jeffro and Ewoks. I thought I had linked my library correctly but I noticed a red X icon by it. It was still referring to my SDK path instead of the local workspace version I had created! Removing and adding the correct one worked. #IAmAnIdiot – Anthony De Souza Sep 30 '14 at 11:55
  • 2
    If it helps, I had to take a few more steps in Android Studio. Went to: Project Structure --> App --> Dependencies --> click + for add option for Library --> play-services (x.x.x). I got an error when I rebuilt and the library added was play-services...0.0. I was missing the Google Play Repositories from the SDK Manager under the Extras. When I came back and repeated those steps the Library now had an actual version number and rebuilt successfully. – natur3 Nov 19 '14 at 15:41
  • @natur3 thanks for adding those extra steps, fixed it for me too! – AdamMc331 Apr 06 '15 at 01:08
36

I got the solution.

  • Step 1: Right click on your project at Package explorer(left side in eclipse)
  • Step 2: goto Android.
  • Step 3: In Library section Add Library...(google-play-services_lib)
    see below buttes

    • Copy the library project at

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

    • to the location where you maintain your Android app projects. If you are using Eclipse, import the library project into your workspace. Click File > Import, select Android > Existing Android Code into Workspace, and browse to the copy of the library project to import it.
    • Click Here For more.
  • Step 4: Click Apply
  • Step 5: Click ok
  • Step 6: Refresh you app from package Explorer.
  • Step 7: you will see error is gone.
Vrajesh
  • 1,312
  • 19
  • 25
30

From here

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.

I faced this error because I referenced the original copy from SDK directory. Make sure that you first copy the library to android workspace and only reference it. In eclipse you can do it by checking "Copy projects into workspace" while importing the project.

22

In Android Studio you can fix this by simply adding this to your Gradle file:

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

EDIT

Now, due to updates and new Gradle API the line you should use is:

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

One more important tip: Avoid using bundled version of Google Play Services, but consider declaring just dependencies that your app needs to reduce it size as well as to reduce unnecessary hit to 65k methods limit. Something like (i.e. for Maps) this would be better than general play-services usage above:

implementation 'com.google.android.gms:play-services-maps:12.0.0'
Ewoks
  • 12,285
  • 8
  • 58
  • 67
Joaquin Iurchuk
  • 5,499
  • 2
  • 48
  • 64
  • Thanks - this helped. I'm trying to do this tutorial and had encountered this error and your solution helped me:https://github.com/googledrive/android-demos – Simon Jan 13 '15 at 18:31
  • 1
    I just needed to clean the project, after the gradle sync, and the missing integer error went away. This works well too: `compile 'com.google.android.gms:play-services-appindexing:7.8.0'` – Someone Somewhere Sep 15 '15 at 03:15
  • 2
    I know it is an old Q/A but people are still stumbling upon it, so it made sense to update it to new AS3 & Gradle APIs and to emphasise urge to use specific library instead of whole bundle. I hope original author doesn't mind – Ewoks Mar 21 '18 at 06:34
7

Just add the library reference, go to Propertes -> Android, then add the library.

enter image description here

then add into you AndroidManifest.xml

   <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
Jorgesys
  • 124,308
  • 23
  • 334
  • 268
3

I had the same problem in Android Studio 1.2.1.1. It was just liske the other answers said, however, I was not able to find where to add the dependencies. Finally I found it under File->Project structure->Dependencies This menu will give you the option at add the dependency to the Google Play Services library.

7heViking
  • 7,137
  • 11
  • 50
  • 94
  • +1 for the help on the obscure navigation in AS 1.2. Thank you! It didn't help, in my case, that I was working on a project handed off from another dev and had never actually installed the right version of the play services library using SDK manager :$. Once I downloaded/installed the library, then I went back and removed/added again and the compile error went away. – Anne Gunn Jul 03 '15 at 16:45
2

try installing 4.0.30 as mentioned in this documentation: http://developer.android.com/google/play-services/setup.html

panchicore
  • 11,451
  • 12
  • 74
  • 100
2

In my case i had to install google repository from the SDK manager.

MarcSB
  • 1,040
  • 1
  • 12
  • 19
1

I was getting the same error; I had previously installed the google-play-services_lib for Google Maps (and it was working fine) but then when I later tried adding the meta-data entry to my Manifest I was getting the error. I tried all the above suggestions but nothing would link them properly; I finally removed the link from my project (project-properties-Android, remove google-play-services_lib library), then removed from Eclipse workspace, deleted the files on the disk, and finally used the SDK manager to reinstall from scratch.

That seemed to finally do the trick; now Eclipse has decided to allow me to leave the meta-data entry with no errors.

dgiles
  • 11
  • 1
  • 1
  • I had the same error, the copy of the google-play-services lib in my workspace was old (so not containing the integer resource), and replacing the lib with an updated version did the trick. – Bianca Daniciuc Sep 25 '14 at 07:10
0

You can change workspace and than fix that problem and than import the fixed project back to your main workspace. Also the 4 steps should be in order hope it helps someone in the future.

sivi
  • 10,654
  • 2
  • 52
  • 51
0

This error can also happen when you've downloaded a new version of Google Play Services and not installed the latest SDK. Thats what happened to me. So, as the others mentioned, if you try to import Google Play Services and then open the console, you'll see a compile error. Try installing all the recent Android SDKs and try again, if this is the case.

UtsavShah
  • 857
  • 1
  • 9
  • 20
0

I did following steps to recover from this:

1) Import google play services as project into your android sdk. In my system it is found at C:\adt-bundle-windows-x86_64-20140702\sdk\extras\google\google_play_services\libproject\google-play-services_lib

2) Your android application-> properties -> android

In the window

2.1) Click on Google APIs in project build target 2.2) Add google-play services in bottom frame and click on OK

Hope it gives clear instruction on what to do !!

Thanks.

pravs
  • 371
  • 1
  • 4
  • 14
0

Replace version code with appropriate code of library version will solve your issue, like this:

 <integer name="google_play_services_version"> <versioncode> </integer>
Sufian
  • 6,405
  • 16
  • 66
  • 120
1'hafs
  • 559
  • 7
  • 25
0

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
fedmich
  • 5,343
  • 3
  • 37
  • 52
0

Simply removing the google play services library from the project and adding once again from sdk->extras->google folder solved my problem perfectly.

Neal Ahluvalia
  • 1,538
  • 1
  • 10
  • 20
0

For my case, I just restart my Eclipse and it works.

I have been working for 2 weeks without shutting it down, I think it goes haywire.

Thanks for the suggestion though Ewoks!

Eddy Goh
  • 256
  • 5
  • 11
-3

Can directly used as

android:value="6587000"

in place of

android:value="@integer/google_play_services_version"

Cheers.

Ali Akram
  • 4,803
  • 3
  • 29
  • 38
-38

You will need to add an "integers.xml" file to your project's "res/values" folder. The contents of the file should be..

<resources>
    <integer name="google_play_services_version">4030500</integer>
</resources>
laalto
  • 150,114
  • 66
  • 286
  • 303
Murray
  • 189
  • 1
  • 11