【问题标题】:Failed to find: com.google.android.gms:play-services-gcm:8.3.0找不到:com.google.android.gms:play-services-gcm:8.3.0
【发布时间】:2016-03-17 04:11:17
【问题描述】:

我正在使用 Android StudioGCM 集成到一个项目中,因为我将 google play 服务依赖项添加到 top level gradle 如下 sn-p 代码:

dependencies {
    classpath 'com.android.tools.build:gradle:1.3.0'
    classpath 'com.google.gms:google-services:1.5.0-beta2'  //this one
}

但我收到错误 Failed to find: com.google.android.gms:play-services-gcm:8.3.0Failed to find: com.google.android.gms:play-services-measurement:8.3.0。我已经从 SDK 管理器更新了 goole play 服务并同步了项目。

我也在顶级 gradle 中添加了 apply plugin: 'com.google.gms.google-services',但它仍然显示相同的错误

【问题讨论】:

  • 在项目级gradle中添加apply plugin: 'com.google.gms.google-services'
  • 我也做过
  • 您是否在项目中添加任何播放服务库??
  • 你可以按照这里的解释试试stackoverflow.com/questions/30527369/…
  • com.google.gms:google-services:1.5.0 我确定已经发布

标签: android android-studio google-cloud-messaging google-play-services


【解决方案1】:

请确保您安装了最新 Android Studio,以及更新 Google Play Services。这也可能是上述错误的原因。此外,您也不需要添加插件行apply plugin: 'com.google.gms.google-services'。没有它它会编译得很好。目前,我正在使用 Android Studio 2.1gradle version 2.10 来编译以下 gradle 配置。

Build.gradle(项目级别)

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.0-alpha3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.google.gms:google-services:2.0.0-alpha6'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Build.gradle(应用模块)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "your.package.id.here"
        minSdkVersion 16
        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.google.android.gms:play-services-gcm:8.4.0'
   }

【讨论】:

    【解决方案2】:

    您不需要引用完整的 google play 服务,只需将 GCM 引用添加到 build.gradel 模块即可。

    这就是我的样子并且工作正常。

    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.8.0'
    }
    

    然后确保运行 build.grade。自从我添加了我的版本后,版本可能也发生了变化。

    还要注意你把它放到了错误的gradel文件中,使用模块而不是顶部的模块

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-01
      相关资源
      最近更新 更多