简体   繁体   中英

Failed to resolve: com.google.android.gms:play-services-gcm:7.5.+

I am trying to include GCM in my app.

I keep getting this error message :

Failed to resolve: com.google.android.gms:play-services-gcm:7.5.+ | Install Repository and sync project | Show in Project Structure dialog

If I try to Install Repository and sync project i get this error:

Loading SDK information... Ignoring unknown package filter 'extra-google-m2repository'Warning: The package filter removed all packages. There is nothing to install. Please consider trying to update again without a package filter.

Here is my gradle file:

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"
    ...

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile 'com.android.support:appcompat-v7:22.2.1'
        compile 'com.google.android.gms:play-services-gcm:7.5.+'

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3'
        classpath 'com.google.gms:google-services:1.3+'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

Could you check that the necessary packages in your Android SDK Manager are up to date.

And use

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

I hope it will helps you .

Changing from 7.5.+ to 7.5.0 fixed this issue for me. I'm not sure why the wildcard caused an issue.

I once encountered the same error after updating Android Studio and SDK.

You could try to use 'com.android.tools.build:gradle:1.3.0' instead of 'com.android.tools.build:gradle:1.2.3' in Project gradle file.

更新SDK为我解决了此问题。

I know this question has been answered well but just to add something for those who come across a similar error and are seeing this page.

Failed to resolve usually pops up when you are updating the dependencies (read google support libraries) to a newer version and your project is using older version of Google Play Services (look in Android SDK Manager under Extras).

To resolve this just update the Google Play Services to the latest version and then Sync your build.gradle (app). This should resolve similar issues.

For what it's worth, I had this error when I updated from 10.1.1 to 10.2.0. I tried using 10.2, but found that I had to use the full version number: 10.2.0 (the last zero matters). Hope this helps someone.

For me - help:

  1. to go to Tools -> Android -> SDK Manager
  2. in Android SDK from left list choice tab SDK Tools
  3. Check all need to update packages
  4. You need a lot of free space on disk and a lot of time (for me with SSD disk it takes about 1 hour)

After that your project should work fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM