gpt4 book ai didi

firebase - Xamarin FirebaseApp.InitializeApp(this) 在 60.1142.1 中返回 null

转载 作者:行者123 更新时间:2023-12-04 14:23:37 25 4
gpt4 key购买 nike

我已经查看了网上关于此错误的所有问题。它似乎在 < 42.1021.1 的版本中非常常见。但是我有最新的版本,但错误仍然存​​在。

我已经添加了我的 google-services.json 并选择了适当的构建操作。我尝试过清理和重建但没有成功。我还尝试了其他版本中的错误解决方法,例如在 csproj 文件中添加 Target 标记。我试过从 json 中手动输入字符串。

无论我调用 FirebaseApp.InitializeApp(this) 做什么,都会返回 null,当我尝试引用 FirebaseInstanceId.Instance.Token 时,我得到了一个非常常见的异常:

Java.Lang.IllegalStateException:默认 FirebaseApp 未在此过程中初始化确保先调用 FirebaseApp.initializeApp(Context)。

Github 和 Xamarin 论坛说这是用 60.1141.1 修复的,但从来没有。我还检查了我的 csproj,以确保对 GoogleServices 的所有引用都是最新版本。

我不知道为什么这行不通,我真的很快就需要它来工作。如果可以,请帮忙。

我查看了以下资源但没有成功: Getting Exception Using Firebase in Xamarin Android https://learn.microsoft.com/en-us/xamarin/android/data-cloud/google-messaging/remote-notifications-with-fcm?tabs=vswin https://bugzilla.xamarin.com/show_bug.cgi?id=56108#c1 Default FirebaseApp is not initialized https://forums.xamarin.com/discussion/94464/firebase-cloud-messaging-app-not-initialized Xamarin.android Default FirebaseApp is not initialized in this process

还有更多我找不到的。为什么这个bug还在这个版本上出现????

最佳答案

我遇到了同样的问题,经过一番调查后,我尝试以这种方式在 OnCreate 方法中手动启动它

var options = new FirebaseOptions.Builder()
.SetApplicationId("<AppID>")
.SetApiKey("<APIKey>")
.SetDatabaseUrl("https://<url>.firebaseio.com")
.SetStorageBucket("*.appspot.com")
.SetGcmSenderId("<senderID").Build();
var fapp = FirebaseApp.InitializeApp(this, options);

LoadApplication(App);

PushNotificationManager.ProcessIntent(this, Intent);

这对我有用,而且构建过程“GoogleServiceJson”似乎不起作用,应该由它来代替。此致,托马斯

关于firebase - Xamarin FirebaseApp.InitializeApp(this) 在 60.1142.1 中返回 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50684222/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com