天天看點

File google-services.json is missing. The Google Services

在将firebase和android項目結合使用時報錯,錯誤資訊如下:

Error:Execution failed for task ':app:processDebugGoogleServices'.
> File google-services.json is missing. The Google Services Plugin cannot function without it. 
   Searched Location: 
  D:\androidProject\FireCastApp\app\src\debug\google-services.json
  D:\androidProject\FireCastApp\app\google-services.json
           

首先說明一下出現這個錯誤的背景:

(1)自己建立一個android project,然後需要使用firebase來進行連接配接。

(2)使用firebase是需要翻牆的,firebase連接配接位址,打開以後界面如下圖所示:

File google-services.json is missing. The Google Services

(3)點選控制台,然後就可以建立一個APP,出現如下圖所示界面:

File google-services.json is missing. The Google Services

注意:項目名稱最好和你的android project Name保持一緻;地區按照你所在地區選擇就可以。

(4)建立成功後,會出現如下圖所示的界面:

File google-services.json is missing. The Google Services

(5)點選android頭像的圖示,可以将firebase添加到你的android應用中,點選以後會出現如下圖所示的界面:

File google-services.json is missing. The Google Services

注意:android軟體包名稱這裡需要填寫你的android studio中的app目錄下的build.gradle檔案中的 applicationId,也就是需要填寫下面的内容:

com.android.lee.firecastapp

下面那個調試簽名證書SHA我目前還不知道怎麼搞,略過,等我會了再補充。

(6)然後你需要在你的app目錄下的build.gradle檔案中添加兩行代碼,如下圖的紅色箭頭所指:

File google-services.json is missing. The Google Services

(7)在你的project中的build.gradle檔案中(不是app目錄下的build.gradle)添加如下的代碼:

File google-services.json is missing. The Google Services

(8)添加所有的東西完畢後,你應該點選這個同步按鈕,來同步整個項目,如下圖所示:

File google-services.json is missing. The Google Services

(9)同步完成以後,你需要把google-services.json檔案從你的firebase控制台下載下傳下來,并且放到你的app目錄下面,如下圖所示:

File google-services.json is missing. The Google Services

到這裡,就把你的android project和firebase聯系到了一起,你可以運作你的項目看看效果。

PS:如有不足之處,還請各位大佬提出改正意見,我是剛開始學習android。

File google-services.json is missing. The Google Services

繼續閱讀