【发布时间】:2021-05-02 05:12:17
【问题描述】:
这是我的应用类
class App : MultiDexApplication() {
override fun onCreate() {
FirebaseApp.initializeApp(this)
Thread.setDefaultUncaughtExceptionHandler(GoExceptionHandler(this))
super.onCreate()
}
}
&这里是异常处理程序
class GoExceptionHandler(val context: Context) : Thread.UncaughtExceptionHandler {
override fun uncaughtException(p0: Thread, p1: Throwable) {
class GoExceptionHandler(val context: Context) : Thread.UncaughtExceptionHandler {
override fun uncaughtException(p0: Thread, p1: Throwable) {
AmplitudeAnalyticsTracker.sendCrashEvent(p1.localizedMessage!!)
// Clearing Cache & data if crash occurrence more than 2 time
if (LocalPreference.getCrashCount() >= 3) {
context.cacheDir.deleteRecursively()
(context.getSystemService(MultiDexApplication.ACTIVITY_SERVICE) as ActivityManager)
.clearApplicationUserData()
} else {
LocalPreference.setCrashCount()
}
}
}
}
}
当我评论 Thread.setDefaultUncaughtExceptionHandler(GoExceptionHandler(this)) 时,崩溃报告在 Crashlytic 控制台中正确,但是当我将它添加到我的 APP 类时,它变成了噩梦,并且在 firebase 上没有崩溃报告
【问题讨论】:
标签: android firebase kotlin firebase-crash-reporting