Adding Google Play services version to your app

2019-01-04 01:12发布

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?

18条回答
在下西门庆
2楼-- · 2019-01-04 01:35

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.

查看更多
Melony?
3楼-- · 2019-01-04 01:40

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>
查看更多
爷的心禁止访问
4楼-- · 2019-01-04 01:43

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

查看更多
Summer. ? 凉城
5楼-- · 2019-01-04 01:44

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

查看更多
祖国的老花朵
6楼-- · 2019-01-04 01:44

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
查看更多
Summer. ? 凉城
7楼-- · 2019-01-04 01:46

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'
查看更多
登录 后发表回答