使用安装了Firebase的自定义崩溃处理程序

时间:2017-04-07 20:01:09

标签: android firebase forceclose firebase-crash-reporting

我一直在使用一个整洁的库来处理强制关闭崩溃:

https://github.com/Ereza/CustomActivityOnCrash

在我决定将Firebase通知添加到我的应用之前,它一直运行良好。我只选择了通知,因此我只添加了以下依赖项:

compile 'com.google.firebase:firebase-messaging:10.0.1'

出于某种原因,Firebase崩溃报告也正在初始化,因为自定义崩溃处理程序会查看它,甚至会显示以下消息:

E/CustomActivityOnCrash: IMPORTANT WARNING! You already have an UncaughtExceptionHandler, 
are you sure this is correct? If you use ACRA, Crashlytics or similar libraries, 
you must initialize them AFTER CustomActivityOnCrash! Installing anyway, but your
original handler will not be called.

我的自定义崩溃处理程序是我的(应用程序)onCreate()方法中初始化的第一件事,因此我不知道在何处或如何阻止Firebase崩溃报告加载/初始化自身。

非常感谢任何帮助!

2 个答案:

答案 0 :(得分:1)

我找到了答案,感谢@ BobSnyder的评论 - 它引导我搜索并找到之前的问题/答案:

How to disable default Firebase crash reporting?

最终我使用这个答案来解决我的问题:

If you want to disable the Firebase Analytics Crash Reporting, use the below 
code inside app.gradle file.

configurations {
    all*.exclude group: 'com.google.firebase', module: 'firebase-crash'
}

答案 1 :(得分:1)

我是该图书馆的开发者。最高1.5.0的版本会导致Firebase崩溃报告停止工作。该应用不会崩溃,但Firebase内部设置的原始UncaughtExceptionHandler将永远不会被调用,因此您的Firebase控制台中不会出现崩溃数据。

即使将CustomActivityOnCrash.install()作为Application类的第一行调用,也会发生这种情况,因为Firebase会将其UncaughtExceptionHandler初始化为提供程序,因此最终会在{{1}之前执行对象被实例化。

该库的2.0.0版本通过使用与Firebase相同的过程(使用提供程序)修复了此问题,但更高Application,因此它在Firebase之前执行。

更新您的依赖项以使其按预期工作(但是,请注意API更改,因为版本2.x与1.x代码不兼容):

initOrder