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'
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! }
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With