如何在Xamarin.Forms项目上集成Firebase.Crashlytics

问题描述:

任何人都可以帮助我将Firebase.Crashlytics集成到iOS的Xamarin.Forms项目中吗?我在Android上运行正常,但在iOS上却遇到了问题.请注意,我已在iOS上执行了以下步骤:-

Can any one help me with integrating Firebase.Crashlytics on a Xamarin.Forms project for iOS. It is working fine for me on Android but on iOS I am facing issues. Note that I have performed the following steps on iOS :-

  1. 已将Xamarin.Firebase.iOS.Crashlytics Nuget包添加到我的iOS项目中.

  1. Added Xamarin.Firebase.iOS.Crashlytics Nuget package to my iOS project.

添加了GoogleService.plist文件

Added GoogleService.plist file

为iOS提供依赖项服务

Made a dependency service for iOS

添加了以下代码以初始化nuget:-

Added the following code to initialize the nuget :-

         Firebase.Core.App.Configure();
         Crashlytics.Configure();
         Fabric.Fabric.SharedSdk.Debug = true;
         Crashlytics.SharedInstance.Crash();

更新

我已按照下面提到的链接中的所有步骤进行操作:- https://keithbeattyblog.wordpress.com/2019/06/16/xamarin-forms-adding-google-firebase-crashylitics/仍然没有任何效果.

I have followed all the steps in the below mentioned link :- https://keithbeattyblog.wordpress.com/2019/06/16/xamarin-forms-adding-google-firebase-crashylitics/ Still nothing works.

当我按照上面的文章中的步骤进行操作时,由于"Xamarin.Build.Download" NuGet程序包,我无法构建项目时会遇到问题.另外,我还遇到无法将解决方案部署到我的模拟器的问题,因为它不允许我选择模拟器来运行该应用程序.

When I follow the steps written in the above article I face issues where I am unable to build my project due to the 'Xamarin.Build.Download' NuGet package. Also I face issues where I am unable to deploy the solution to my Simulators because it doesn't allow me select a simulator to run the App.

任何帮助将不胜感激.谢谢!

Any help would be appreciated. Thanks!

您确定要继续使用旧的Fabric实现吗?您必须知道Fabric Crashlytics版本已弃用,对吧?

Are you sure you want still go with the old Fabric implementation? You must be aware that the Fabric Crashlytics version is deprecated, right?

我们所有人都收到了Google的邮件,通知您:

All of us were received a mail from Google informing that:

我们谨在此通知您,Fabric Crashlytics SDK已被弃用,并将继续报告您应用的崩溃,直到2020年11月15日.在此日期之后,Fabric Crashlytics SDK和Firebase Crashlytics SDK的Beta版将停止发送崩溃报告您的应用程序.发生了什么?我们将用通用的Firebase替换Fabric Crashlytics SDK和Firebase Crashlytics SDK的beta版本Crashlytics SDK.下一步是什么?要继续在Firebase控制台中获取崩溃报告,请确保将您的应用升级到Firebase Crashlytics SDK版本2020年11月15日之前适用于Android的17.0.0+,适用于iOS的4.0.0+和适用于Unity的6.15.0 + .Android

We are writing to let you know that the Fabric Crashlytics SDK is now deprecated and will continue reporting your app's crashes until November 15, 2020. After this date, the Fabric Crashlytics SDK and beta versions of the Firebase Crashlytics SDK will stop sending crash reports for your app.What happened? We are replacing Fabric Crashlytics SDKs and beta versions of the Firebase Crashlytics SDKs with the generally available Firebase Crashlytics SDKs.What's Next? To continue getting crash reports in the Firebase console, make sure to upgrade your apps to the Firebase Crashlytics SDK versions 17.0.0+ for Android, 4.0.0+ for iOS, and 6.15.0+ for Unity before November 15, 2020.Android

所以一切都会很快改变,您不应该再使用Fabric解决方案,尤其是对于新项目.

So everything is going to change soon, and you shouldn't use the Fabric solution anymore, especially for new projects.

您可以在此处找到新的官方nuget程序包,但仍在预览中:

You can found the new official nuget package here, but it is still in preview:

https://www.nuget.org/packages/Xamarin.Firebase.Crashlytics/117.0.0-preview02

这是添加注释的官方存储库问题: https://github.com/xamarin/XamarinComponents/issues/956

This is the official repository issue to add comments: https://github.com/xamarin/XamarinComponents/issues/956

当您添加此新程序包和google-services.json时,您需要在旧代码中更改以下内容:

When you'll add this new package and the google-services.json you will need to change the following in your old code:

  • 每个 CrashLytics.Crashlytics 参考都只是 FirebaseCrashlytics .
  • 不需要初始化,您可以在任何地方获取 FirebaseCrashlytics.Instance
  • 要记录异常,您将需要使用 RecordException 方法而不是旧的 LogException
  • SetUserIdentifier 更改为 SetUserId ,并且 SetUserName 不再存在
  • 再也没有办法故意崩溃,因此,如果您想测试实现,现在只需要抛出想要的任何异常即可
  • Every CrashLytics.Crashlytics reference will be just FirebaseCrashlytics.
  • No initialization is needed, you can get the FirebaseCrashlytics.Instance anywhere
  • To log an exception you will need to use the RecordException method instead of the old LogException
  • SetUserIdentifier is changed to SetUserId, and SetUserName is no longer there
  • There is no method to crash on purpose anymore, so now you have to simply throw any exception you want if you wanna test your implementation

也许我遗漏了一些东西,但是基本上,仅此而已.

Maybe I'm missing something, but basically, that's all.