How to find google play service version in Android

2019-04-02 17:08发布

问题:

I am trying to use google play services for location purposes. Therefore I wanted to add google play services to my app. In build.gradle dependincies I added following line.

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

However it gives following error

 Error:(25, 13) Failed to resolve: com.google.android.gms:play-services:9.0.1

I couldnt find which version of Google play services installed. In SDK Tools tab it says version 30.

I've tried following line too but it also gave same error

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

Edit: Here is the whole build.gradle file.

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "ozu.cs394.umurali.whereismycar"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.google.android.gms:play-services:9.0.1'
}

回答1:

you should update google play services repository in sdk manager:



回答2:

  • Go to File -> Project Structure
  • Select 'Project Settings'
  • Select 'Dependencies' Tab
  • Click '+' and select '1.Library Dependencies'
  • Search for : com.google.android.gms:play-services
  • Select the latest version and click 'OK'


回答3:

Check your SDK Manager under Extras and make sure that Google Repository is installed.