![](/img/trans.png)
[英]IllegalStateException: Default FirebaseApp is not initialized in this process. Make sure to call FirebaseApp.initializeApp(Context) first
[英]Default FirebaseApp is not initialized in this process. Make sure to call FirebaseApp.initializeApp(Context) first
默認 FirebaseApp 在此過程中未初始化。 確保先調用 FirebaseApp.initializeApp(Context)。
我嘗試了很多東西,但我無法在設備中獲取通知。
我也試過下面的東西。
在 Properties 窗格中,在 Solution Explorer 窗口中設置 Build Action Select google-services.json。
在 Properties 窗格中,將 Build Action 設置為 GoogleServicesJson(如果未顯示 GoogleServicesJson 構建操作,請保存並關閉解決方案,然后重新打開它):to GoogleServicesJson
通知之前有效,但在我將 xamarin 表單更新為 2.5.0.280555 和 Xamarin.Firebase.Messaging.42.1021.1 后,它停止工作。
對我來說,任何地方都提供的解決方案都行不通。 只有這個有效。 只需將我的谷歌服務從 4.1.0 降級到 4.0.0
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0-alpha08'
classpath 'com.google.gms:google-services:4.0.0'
/*classpath 'com.google.gms:google-services:4.1.0' <-- this was the problem */
}
因此,如果您更新了谷歌服務,只需嘗試降級或更改為舊版本即可。 希望能幫助到你
將插件添加到 build.gradle(應用程序級別)
// 在底部添加這個
apply plugin: 'com.google.gms.google-services'
確保:
AndroidManifest.xml
中的包名稱與google-services.json
中的包名稱相同google-services.json
構建操作設置為GoogleServicesJson
FirebaseApp.InitializeApp(Application.Context);
在LoadApplication(..)
之前的MainActivity.OnCreate
中對我來說,當我忘記在應用程序模塊中添加第二個插件時就會發生這種情況
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services' // Google Services plugin
添加此插件后,您可以嘗試其他人的建議。
將com.google.gms:google-services
升級到最新版本即可解決。
升級
com.google.gms:google 服務
到最新版本,它會解決。
這個對我有用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.