Google服务未能在 Google 云消息中初始化

GoogleService failed to initialize in Google Cloud Message

我在 Android 应用程序中使用 google 云消息。我按照步骤here

当我 运行 应用程序时,logcat 显示警告消息:

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.

E/GMPM: Scheduler not set. Not logging error/warn.

E/GMPM: Uploading is not possible. App measurement disabled

但我仍然可以获得令牌,当我使用 Google gcm 示例代码测试 push(gcmsender) 时,它工作正常(我可以接收推送),我添加了生成的配置文件Google 对我的项目调用了“google-services.json”, 和我的应用 gradle :

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.google.android.gms:play-services-analytics:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'}

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

我的项目gradle:

buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:1.5.0'
    classpath 'com.google.gms:google-services:1.3.0-beta4'

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

我不明白为什么 logcat 上会显示警告消息,我按照步骤操作,应用程序运行正常,有人知道吗?

编辑:问题已解决, 只需在 string.xml 文件中添加您的应用程序 ID, Google console

找到“project_id”,然后复制到您的string.xml

<!-- App id -->
<string name="google_app_id">your project id</string>

添加您的应用程序 ID(从 google 控制台获取)并将其添加到 string.xml

<!-- App id -->
<string name="google_app_id">appId</string>