【问题标题】:Upgrade to Google Play Services:9.0.0 Error Failed to resolve: com.google.android.gms:play-services-measurement:9.0.0升级到 Google Play 服务:9.0.0 错误无法解决:com.google.android.gms:play-services-measurement:9.0.0
【发布时间】:2016-09-15 15:49:17
【问题描述】:

我从

升级了我的 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

【问题讨论】:

  • 您是否在 SDK 管理器中更新了您的 Google 存储库?
  • 嗯...当我在我的 SDK 中查看 play-services:9.0.0 的 POM 时,我没有将 play-services-measurement 视为依赖项,并且没有 9.0.0play-services-measurement。您是否手动请求play-services-measurement?如果没有,请尝试清理项目,或使用--refresh-dependencies 开关执行命令行gradle 构建,以尝试让它停止寻找play-services-measurement。不过,总的来说,您可能最好使用更集中的依赖项(您已注释掉的那些)而不是“厨房水槽”play-services 一个。
  • 1.我根本没有要求播放服务测量,在我的代码中没有。 2. 因为这个错误,我切换到“厨房水槽”播放服务。 3. 我可能不得不做这个我以前从未做过的刷新。
  • * 出了什么问题:配置项目 ':app' 时出现问题。 > 无法解析配置“:app:_debugCompile”的所有依赖项。 > 找不到 com.google.android.gms:play-services-measurement:9.0.0。在以下位置搜索:jcenter.bintray.com/com/google/android/gms/….0.0/play-services-measurement-9.0.0.pom
  • 假设下面的答案不能解决您的问题,您需要确定是什么试图加载该依赖项(特别是该版本)。从 9.0.0 开始,play-services 不再需要它,所以肯定有其他东西需要它。

标签: android google-play-services


【解决方案1】:

发现这可以解决问题。

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

【讨论】:

  • 如果有人没有找到它...必须在顶层 build.gradle 中进行此更改....这对我有用,但后来我收到此错误“缺少 api_key/current_key 对象",所以我不得不应用这个解决方案stackoverflow.com/a/37317752/50730
  • 我收到旧错误“属性“方向”已被定义”。将 google-services 类路径更新为 3.0.0。并在 google-services.json 文件中生成启用 GCM 和添加的服务器 API 密钥。有人可以帮我吗?
  • 现在错误已更改为“错误:任务 ':app:processFreeDebugGoogleServices' 的执行失败。> 缺少 api_key/current_key 对象”???
  • 恕我直言,有人能解释一下为什么这个“修复”有效吗?我发现只提供建议的 SO 答案的质量,没有指出原始失败的文档或核心原因,几乎没有帮助,并可能导致更多的混乱。
  • 仍然出现错误错误:找不到 com.google.android.gms:play-services-maps:9.2.0。要求:app_1:app:unspecified 在 build.gradle 文件中搜索
【解决方案2】:

GCM 一直是rebrandedFirebase 云消息传递(FCM),如果你想使用com.google.android.gms:play-services:9.0.0 阅读这篇文章FCM。 这样做可能可行,修改您的build.gradle 文件以使用该插件。

buildscript {
  dependencies {
    // Add this line
    classpath 'com.google.gms:google-services:3.0.0'
  }
}

【讨论】:

  • 我得到了这个错误但是Error:Execution failed for task ':app:processDebugGoogleServices'. > Missing api_key/current_key object
  • @ShajeelAfzal 通过生成 google-service.json developers.google.com/mobile/add 来解决这个问题
  • 我必须将我的项目导入到 firebase 控制台并重新生成 google-service.json 文件才能为我工作。将您的项目导入firebase,然后单击“管理”,如果上述方法不适合您,您可以下载一个新文件
  • 为什么是 3.0.0?不是旧版吗。我相信我们已经在 9.4.0 上。
  • @IgorGanapolsky 版本 3.0.0 用于 gradle 插件,9.4.0 用于库
【解决方案3】:

Required: Latest versions of Android Studio and Google Play Services

您可以通过更新顶级 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'

【讨论】:

  • 我收到“无法下载 Google-services.jar (com.google.gms:google-services:3.0.0)
  • 该链接仅提供您提供的其他建议,并且该链接已过时。从那时起,版本号发生了很大变化。
  • @AndrewS 请提供您的build.gradle。你可以问这个问题。
  • @AndrewS 请检查我编辑的答案。之后clean-rebuild-gradle
【解决方案4】:

我通过将 Gradle 中的字符串更改为

解决了这个棘手的问题
compile 'com.google.android.gms:play-services:9.0.0' //or latest version

【讨论】:

    【解决方案5】:

    我发现最简单的方法是为所有人使用最新版本。

    dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    //apply plugin: 'com.google.gms.google-services' //Firebase
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha8'
    compile 'com.google.firebase:firebase-auth:10.2.6'
    compile 'com.google.android.gms:play-services-auth:10.2.6' //10.2.6
    compile 'com.google.firebase:firebase-core:10.2.6' // used for FCM
    compile 'com.google.firebase:firebase-messaging:10.2.6' // used for FCM
    testCompile 'junit:junit:4.12'
    //  apply plugin: 'com.google.gms.google-services'
    

    }

    解释

    apply plugin: 'com.google.gms.google-services' // 在底部添加这个。

    • 首先,apply plugin: 'com.google.gms.google-services' // 在底部添加。
    • 然后,将这些添加到依赖项中

      compile 'com.google.firebase:firebase-auth:10.2.6' // 确保这是最新版本。

      compile 'com.google.android.gms:play-services-auth:10.2.6' //10.2.6 最新

      compile 'com.google.firebase:firebase-core:10.2.6' // 用于 FCM

      compile 'com.google.firebase:firebase-messaging:10.2.6' // 用于 FCM

    假设如果您的 firebase-auth 10.2.6 是 2017 年 5 月 25 日最新的,但同时您使用的是 play-services-auth:9.0.0 或低于最新版本,那么它们都可以t 建立连接并向您显示错误。

    我希望这会有所帮助。

    【讨论】:

      【解决方案6】:

      将播放服务更改为 10.2.1 以上版本时,我的依赖项开始无法解析。

      我发现更改以下 maven URL 解决了这个问题:

      maven { url 'https://raw.githubusercontent.com/onepf/OPF-mvn-repo/master/' }
      

      maven { url 'https://github.com/onepf/OPF-mvn-repo/raw/master/' }
      

      URL 更改可能会避免在 gradle 或 maven 中缓存它并解决它。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-10-09
        • 1970-01-01
        • 2015-11-16
        • 2016-09-16
        • 2017-12-15
        • 2016-09-15
        • 2017-03-04
        • 2016-11-02
        相关资源
        最近更新 更多