zihadrizkyef
zihadrizkyef

Reputation: 1941

How to send crashlytic NON FATAL ERROR without waiting for FATAL ERROR?

i made a test to understand how Crashlytics works. I make 2 button in my app, 1 for NON FATAL reporting, and 1 for FATAL CRASH reporting. The code looks like this :

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    nonfatal.setOnClickListener {
        val crashlytics = FirebaseCrashlytics.getInstance()
        crashlytics.setUserId(Random.nextInt().toString())
        crashlytics.recordException(Throwable("AAA"))
    }

    fatal.setOnClickListener {
        throw Exception("This is fatal")
    }
}

Then i try to press NON FATAL button then restart my app. I don't see any change to my crashlytic console. But when i press the FATAL button, the app crash, then i reopen the app. Not long after that i see new records in my crashlytic console. Including the NON FATAL report

So the conclusion is, crashlytics doesn't send NON FATAL right away. It just save it, then when the app crash, it send the FATAL and NON FATAL to Firebase.

QUESTION : How to force Firebase Crashlytics to send NON FATAL error to Firebase Console without waiting the app to crash?

Upvotes: 2

Views: 4669

Answers (3)

othomas
othomas

Reputation: 256

You have to make sure your app is fully terminated and relaunched, not just backgrounded and foregrounded.

Then during the next full/cold launch Crashlytics will send both Non-Fatal as well as Fatal errors from the prior session.

Upvotes: 1

zihadrizkyef
zihadrizkyef

Reputation: 1941

Well, I don't know how to forcefully send a NON FATAL error to Firebase console. From what I understand, the NON FATAL error is still not sent when you restart your application. This is because your application is not really killed. So if you want to send NON FATAL, then you have to kill your app from recent apps. When you relaunch your app again, you will be able to find the NON FATAL error in your Firebase console

Upvotes: 1

Oleg Kodysh
Oleg Kodysh

Reputation: 1044

The app does not need to crash for the non fatal to be sent. It just needs for you to end the app session, and then relaunch the app.

You can read more about the process here,

"Crashlytics processes exceptions on a dedicated background thread, so the performance impact to your app is minimal. To reduce your users’ network traffic, Crashlytics batches logged exceptions together and sends them the next time the app launches."

Upvotes: 5

Related Questions