升级到 Google Play 服务:9.0.0 错误无法解决:com.google.android.gms:play-services-measurement:9.0.0

新手上路,请多包涵

我升级了我的 build.gradle 文件

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

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

现在我收到了以前没有收到的错误。

错误:解析失败:com.google.android.gms:play-services-measurement:9.0.0 在此处输入图像描述

在此处输入图像描述

原文由 Philip Herbert 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 1.5k
2 个回答

发现这可以解决问题。

将项目级 gradle 中的类路径 com.google.gms:google-services:2.1.0 更新为类路径 com.google.gms:google-services:3.0.0

原文由 user3330522 发布,翻译遵循 CC BY-SA 3.0 许可协议

必需:最新版本的 Android Studio 和 Google Play 服务

您可以通过更新顶级 build.gradle 和应用级 build.gradle 文件来将插件添加到您的项目中,如下所示:

 classpath 'com.google.gms:google-services:3.0.0'

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

buildscript {
    repositories {
        jcenter()
        mavenLocal()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.0'
        classpath 'com.google.gms:google-services:3.0.0'

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

allprojects {
    repositories {
        jcenter()
        mavenLocal()
    }
}

现在,您需要添加对 Google Play 服务的依赖。在您应用的 build.gradle 中 添加:

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

最后

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.2"

    defaultConfig {
        applicationId "// set Yours"
        minSdkVersion 15
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'LICENSE.txt'
    }
}

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

}

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

原文由 IntelliJ Amiya 发布,翻译遵循 CC BY-SA 3.0 许可协议

推荐问题