com.google.android.gms:play-services-gcm:8.4.0会导致错误

时间:2016-02-05 18:44:12

标签: android google-cloud-messaging

在我的项目中,我使用的是以下版本的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
}

1 个答案:

答案 0 :(得分: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