Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to log non-fatal (caught) exceptions with Firebase (Crashlytics)

I started using Firebase (Crashlytics) in my project to track app crashes. It works perfectly with crashes but how can I log non-fatal crashes, i.e. caught exceptions. I tried Crashlytics.logException(e) but it doesn't work. I see no reports in the dashboard. I saw answers suggesting to use FirebaseCrash.report(t) but this class doesn't exist in the latest version of Firebase. So does anyone know how it's done?

Dependencies:

implementation 'com.google.firebase:firebase-core:16.0.0' implementation 'com.crashlytics.sdk.android:crashlytics:2.9.3' 

enter image description here

like image 555
Egis Avatar asked Aug 06 '18 19:08

Egis


People also ask

How do I log exception in Crashlytics?

You can also use Crashlytics below features to provide more information. Logging Non-Fatal Events: try { myMethodThatThrows(); } catch (Exception e) { Crashlytics. logException(e); // handle your exception here! }

What is non-fatal event in Crashlytics?

In addition to automatically reporting your app's crashes, Crashlytics lets you record non-fatal exceptions and sends them to you the next time your app launches. Note: Crashlytics only stores the most recent eight exceptions in a given app session.

What is non-fatal exception in Firebase?

Non-Fatal logging is where we start using the advanced features of Crashlytics which helps in diagnosing and fixing issues beyond the crashes logged while the app was being used. When exceptions are logged manually in Firebase, they are logged as non-fatals.


1 Answers

With the new Firebase Crashlytics you should use recordException(@NonNull Throwable throwable)

... catch (e: Exception) {     FirebaseCrashlytics.getInstance().recordException(e) } ... 

Here is firebase documentation stating that

like image 120
Akbolat SSS Avatar answered Oct 13 '22 12:10

Akbolat SSS