升级到Google Play Services:9.0.0错误无法解决:com.Google.android.gms:Play Services度量值:9.0.0

升级到Google Play Services:9.0.0错误无法解决:com.Google.android.gms:Play Services度量值:9.0.0,android,google-play-services,Android,Google Play Services,我从升级了build.gradle文件 compile 'com.google.android.gms:play-services:8.4.0' 到 编译'com.google.android.gms:play services:9.0.0' 现在我得到了以前没有的错误 错误:未能解决:com.google.android.gms:play services度量值:9.0.0 发现这可以解决问题 如果您想使用com.google.android.gms:play services:9.0,请

我从升级了build.gradle文件

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

编译'com.google.android.gms:play services:9.0.0'

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

错误:未能解决:com.google.android.gms:play services度量值:9.0.0


发现这可以解决问题


如果您想使用
com.google.android.gms:play services:9.0
,请阅读本文。 若要做到这一点,请修改
build.gradle
文件以使用插件

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

您可以通过更新顶级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服务添加一个依赖项。在应用程序的构建中。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'

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

compile 'com.google.android.gms:play-services:9.0.0' //or latest version

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

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'
    //制作suere这是最新版本

    编译'com.google.android.gms:play services auth:10.2.6'
    //10.2.6最新版本

    编译'com.google.firebase:firebase核心:10.2.6'
    //用于FCM

    编译'com.google.firebase:firebase消息:10.2.6'
    //用于FCM

假设您拥有firebase auth 10.2.6,最新版本为2017年5月25日,但同时您使用的播放服务auth:9.0.0或低于最新版本,则它们都无法建立连接并向您显示错误


我希望这有帮助。

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

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'
我发现更改以下maven URL解决了这个问题:

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


URL更改可能会避免将其缓存在gradle或maven中,从而解决此问题。

您是否在SDK管理器中更新了您的Google存储库?嗯。。。当我在SDK中查看
play services:9.0.0
的POM时,我不认为
play services measurement
是一个依赖项,也不存在
play services measurement
9.0.0
。您是否手动请求播放服务测量?如果没有,请尝试清理项目,或使用
--refresh dependencies
开关执行命令行
gradle
生成,以尝试使其停止查找
播放服务度量。不过,总的来说,您最好使用更集中的依赖项(您已经注释掉的依赖项),而不是“厨房水槽”
play services
one.1。我根本没有要求播放服务测量,我的代码中没有任何地方。2.由于这个错误,我切换到“厨房水槽”播放服务。3.我可能必须执行我以前从未执行过的刷新。*出错原因:配置项目时出现问题:“:app”“>无法解析配置“”的所有依赖项:应用:_debugCompile'>找不到com.google.android.gms:play-services-measurement:9.0.0。在以下位置搜索:.0.0/play-services-measurement-9.0.0.pom假设下面的答案不能解决您的问题,您需要确定尝试加载该依赖项的内容(尤其是该版本)<代码>播放服务
不再需要它,从9.0.0开始,因此一定有其他人需要它。如果有人找不到它。。。此更改必须在顶级版本中进行。gradle。。。。这对我来说很有效,但后来我遇到了这个错误“缺少api_键/当前_键对象”,所以我不得不应用这个解决方案,我得到了旧的错误“属性“方向”已经定义”。将google服务类路径更新为3.0.0。并在google-services.json文件中生成启用的GCM和添加的服务器API密钥tat。有人能帮我吗?现在错误变为“错误:任务执行失败”:app:ProcessFreeDebuggeGoogleServices.>缺少api\u key/current\u key对象”?恕我直言,有人能解释一下为什么这个“修复”有效吗?我发现仅仅给出一个建议,而不指向文档或原始失败的核心原因的SO答案的质量几乎没有帮助,并可能导致更多的混乱。仍然得到错误:找不到com.google.android.gms:play services maps:9.2.0。必需:app_1:app:unspecified我收到此错误,但是
错误:任务执行失败:app:processDebugGoogleServices'>缺少api_key/current_key object
@ShajeelAfzal通过生成google-service.json来解决这个问题。我必须将我的项目导入firebase控制台,并重新生成google-service.json文件,以便它为我工作。将您的项目导入firebase,然后单击“管理”,然后您可以下载一个新文件,如果上述内容不适用于您为什么3.0.0?那不是旧版本吗。我相信我们已经在9.4.0上了。@IgorGanapolsky 3.0.0版是gradle插件,9.4.0版是图书馆版。我无法下载Google-services.jar(com.Google.gms:Google services:3.0.0),该链接除了你给出的建议之外没有其他建议,而且该链接已经过时。自那以后,版本号有了很大的变化。@AndrewS请提供您的
build.gradl