Could not find com.google.android.gms:play-service

2020-08-09 06:42发布

问题:

I have this log from Android Studio gradle:

Error:A problem occurred configuring project ':ParseStarterProject'.
> Could not resolve all dependencies for configuration ':ParseStarterProject:_debugCompile'.
   > Could not find com.google.android.gms:play-services:7.5.0.
     Searched in the following locations:
         https://repo1.maven.org/maven2/com/google/android/gms/play-services/7.5.0/play-services-7.5.0.pom
         https://repo1.maven.org/maven2/com/google/android/gms/play-services/7.5.0/play-services-7.5.0.jar
     Required by:
         Parse:ParseStarterProject:unspecified

How in the world it can't look locally where it is (other projects clearly see and normally compile)?

    apply plugin: 'com.android.application'
apply plugin: 'com.parse'

buildscript {
  repositories {
    mavenCentral()
      jcenter()
    maven { url 'https://maven.parse.com/repo' }
  }
  dependencies {
    classpath 'com.parse.tools:gradle:1.+'
  }
}

dependencies {
    compile 'com.google.android.gms:play-services:7.5.0'
    compile 'com.parse.bolts:bolts-android:1.2.0'
    compile fileTree(dir: 'libs', include: 'Parse-*.jar')
    compile fileTree(dir: 'libs', include: 'ParseCrashReporting-*.jar')
}

android {
    compileSdkVersion 22
    buildToolsVersion "20"

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 22
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            res.srcDirs = ['res']
        }
    }
}

/* Uncomment if you enable ProGuard and you want to automatically upload symbols on build.
parse {
  applicationId YOUR_APPLICATION_ID
  masterKey YOUR_MASTER_KEY

  // Make symbol upload automatic. Otherwise, use e.g. ../gradlew parseUploadSymbolsDebug;
  uploadSymbols true
}
*/

You mean that? There are two of these so I put the one in case.

edit: build.gradle (module)

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {

        classpath 'com.android.tools.build:gradle:1.2.3'
        classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.+'
    }
}

allprojects {
    repositories {
        mavenCentral()
    }
}

ext {
    compileSdkVersion = 22
    buildToolsVersion = "22"

    minSdkVersion = 9
    targetSdkVersion = 22
}

回答1:

Open SDK Manager and update Google Play services and Google Repository. Its works for me.



回答2:

i had the same issue today: i resolved simply by updating the google repository: Tools->android->SDK manager->Extras. When you have updated, you should be able to import use the dependence



回答3:

I solved my problem by change the dependencies

From

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

To

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

and update build tools from 22 to 23



回答4:

You must download the appropriate SDK package in Android Studio as described in the docs.

Steps:

  1. Tools -> Android -> SDK Manager
  2. Select Google Play services
  3. Install


回答5:

In my case Android Studio said that Play Services 9.4.2 was available, and I got same error. Then I changed to version 9.4.0 which was indicated in official docs. And error disappeared.



回答6:

I had this problem like yesterday and nothing seemed to work: I had Android Support Repository and Google Play Services up to date and everything...

Turns out the environment variable ANDROID_HOME was pointing to the wrong folder when looking for the android sdk folder. To change that I had to set it right in the .profile file at the root of my MacBook.

Here's the syntax to do so : export ANDROID_HOME='/Users/SteeveO/Library/Android/sdk'

Hope it helps someone in the future!