Search code examples
androidfirebaseexceptionfirebase-crash-reporting

How to report exceptions in android project automatically to Firebase?


I've seen the option of automatic crash reports to firebase. But what about regular try/catch exceptions? Is there any way to set automatic logs to Firebase on each caught exception in my android app?


Solution

  • Once you use the Firebase Crash Reporting SDK in your app, uncaught exception are automatically reported to the server.

    To report an exception that you catch, cal FirebaseCrash.report:

      ...
    }
    catch (IOException ex) {
        FirebaseCrash.report(ex);
    }
    

    I highly recommend reading the Firebase Crash Reporting documentation. It's pretty much a single page and covers the entire API and many common use-cases.