1. 程式人生 > >使用Firebase過程中出現的異常

使用Firebase過程中出現的異常

一、Could not get unknown property 'compile' for object

編譯器報下面的錯誤,請檢查build.gradle並調整格式

Error:(30, 0) Could not get unknown property 'compile' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.


原因:studio新增程式碼的位置可能不對,或者改變了程式碼的格式,造成studio識別不了


解決方法:修改錯誤的程式碼格式,如上圖compile的位置不對,需要調整


二、The Google Service Plugin cannot function without it

Information:Gradle tasks [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies]
Error:Execution failed for task ':app:processDebugGoogleServices'.
> File google-services.json is missing. The Google Services Plugin cannot function without it. 
   Searched Location: 
  E:\MyApplication3\app\src\debug\google-services.json
  E:\MyApplication3\app\google-services.json


原因:缺少google-services.json檔案,該檔案是在Firebase服務端建立專案後自動生成並下載的

解決辦法:在服務端https://console.firebase.google.com/?pli=1註冊登陸並建立工程,點選專案所需要的模組下,然後點選開始應用,按提示步驟執行,將中間生成的google-service.json檔案拷貝到應用的根目錄

參考資料:https://developers.google.com/identity/sign-in/android/start-integrating