【问题标题】:com.google.android.gms:play-services-gcm:8.4.0 leads to errorcom.google.android.gms:play-services-gcm:8.4.0 导致错误
【发布时间】:2016-02-07 14:15:12
【问题描述】:

在我的项目中,我使用的是以下版本的 GCM 库。

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

现在我将它更新到以下版本

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

但我收到以下错误。

02-05 23:51:29.205 18410-18410/com.example.app E/GMPM: GoogleService failed to initialize, status: 10, Missing an expected resource: 'R.string.google_app_id' for initializing Google services.  Possible causes are missing google-services.json or com.google.gms.google-services gradle plugin.
02-05 23:51:29.205 18410-18410/com.example.app E/GMPM: Scheduler not set. Not logging error/warn.
02-05 23:51:29.238 18410-18452/com.example.app E/GMPM: Uploading is not possible. App measurement disabled

请帮我解决这个问题。

我也用以下配置了我的项目

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

.

 dependencies {
    classpath 'com.android.tools.build:gradle:1.5.0'
    classpath 'com.google.gms:google-services:1.3.0'


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

【问题讨论】:

    标签: android google-cloud-messaging


    【解决方案1】:

    较新版本的 GoogleServices 需要一个 JSON 文件,其中包含有关您的应用和帐户的配置信息。

    关注instructions provided here

    通过升级到最新的构建工具(截至 2016 年 2 月 5 日),您可能还会看到更好的结果:

    buildToolsVersion "23.0.2"
    

    classpath 'com.android.tools.build:gradle:2.0.0-beta2'
    classpath 'com.google.gms:google-services:2.0.0-beta2'
    

    新工具希望将 google-services 插件应用到构建文件的底部,如this example 所示。 FWIW,我正在使用这些设置进行构建,但没有看到错误。

    有关google-services.json 文件的其他信息以及故障排除提示是provided here

    【讨论】:

    • 是的。当然。我已经在以前的版本 play-services-gcm:7.8.0 中配置了 google-services.json 并将其添加到我的项目中。我尝试再次更改它。但是看到了同样的错误。
    • 试用版是否添加了 beta 前缀?那么永远用beta版好不好?
    • @VinilChandran:我不确定你在问什么。这些工具似乎一直在发展和改进。我尽量接近最新发布的版本。发行说明是 herehere
    • @qbix 感谢您的帮助。在您的帮助下,我已经解决了这个问题。我还将 C:\Program Files\Android\Android Studio\gradle\ 里面的 gradle 从 gradle-2.8 更改为 gradle-2.10。
    猜你喜欢
    • 2018-01-04
    • 2016-03-17
    • 2023-03-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-07-23
    相关资源
    最近更新 更多