2016-02-05 46 views
0

在我的項目中,我使用的是以下版本的GCM庫。com.google.android.gms:play-services-gcm:8.4.0導致錯誤

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

較新版本的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' 

新工具預計谷歌的服務插件應用於構建文件的底部,如this example所示。 FWIW,我正在建立這些設置並沒有看到錯誤。

有關google-services.json文件的其他信息,包含疑難解答提示,其他信息是provided here。 30。

+0

Ya。當然。我已經在之前的版本play-services-gcm:7.8.0中配置並將該google-services.json配置到我的項目中。我試着再次改變它。但同樣的錯誤被看到。 –

+0

@VinilChandran:我更新了我的答案。 –

+0

測試版是前綴添加到試用版嗎?那麼使用beta版永遠不錯? –