且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Firebase 崩溃报告如何初始化

更新时间:2023-10-11 23:00:34

更新:现在有一篇关于 Firebase 组件如何初始化.

Update: There is now a comprehensive blog post about how Firebase components initialize.

Firebase 崩溃报告(除其他 Firebase 组件外)在自动包含在您的应用中的 ContentProvider 中进行初始化.ContentProviders 首先被实例化,然后是你的 Application 子类,然后是任何被调用的组件(Activity、Service、BroadcastReciever).

Firebase Crash Reporting (in addition to other Firebase components) initialize in a ContentProvider that's included into your app automatically. ContentProviders are instantiated first, then your Application subclass, then whatever component was invoked (Activity, Service, BroadcastReciever).

当您的项目依赖于 Android 库项目(aar 文件)时,其所有清单条目都会合并到您的应用中,因此您只需声明对 firebase-crash 的依赖即可免费获得此 ContentProvider.

When your project depends on an Android Library project (aar file), all of its manifest entries are merged into your app, so you get this ContentProvider for free simply by declaring declaring the dependency on firebase-crash.

我在 2016 年 Google I/O 大会上发表了关于这一切如何运作的演讲.跳转到 16:22 以查看特定于崩溃报告的内容的开头.

I gave a talk at Google I/O 2016 about how this all works. Jump to 16:22 for the beginning of the content specific to crash reporting.

很遗憾,目前无法以编程方式启用或禁用崩溃报告,但即将推出.

Unfortunately there is currently no way to programmatically enable or disable crash reporting, but that is coming soon.