How to report a crash in Android via Firebase Crash Reporting

How to report a crash in Android via Firebase Crash Reporting

Ones your app is published, it is difficult the understand the reason why the app is crashed. And hence it becomes very difficult to fix them. Crash reporting frameworks log the crashes and grouped into clusters of similar stack traces, and triaged by the severity of impact on your users.

Firebase Crash Reporting is yet another Firebase feature announced at Google I/O 2016. It enable you to collect the detailed report of errors in your app.

Firebase Crash Reporting automatically logs the crashes and you may also log custom events to help capture the steps leading up to a crash.

Firebase Crash Reporting gives you the device details, performance data, user data, when error occurred and what kind of error it is. All the errors will be arranged in a groups according to error types and number of occurrences.

Firebase Crash Reporting is free to use.

Also you can read comparison Firebase Crash Report to Crashlytics, Apteligent and Bugsnag here.

To configure the project to use the Firebase platform, open the Firebase Assistant window by clicking on Tools > Firebase. Now from the assistant go to Crash Reporting and click Set up Crash Reporting. Next, press the Connect to Firebase button and make sure that the Create new Firebase project option is selected. Finaly, click Add Crash Reporting.

android_firebase_crash_setup.png

Now you have connected Firebase platform with Crash Reporting. Also you can manage your Firebase data from Firebase console.

Block of dependencies in your build.gradle file should look like following

dependencies {
    ...
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.google.android.gms:play-services:9.8.0'
    compile 'com.google.firebase:firebase-crash:10.0.1'
}

Firebase Crash Reporting automatically generates reports for fatal errors. However, if you want to report your own exception, you can do it using FirebaseCrash.report(exception) method. For example:

Exception exception = new Exception("Oops! Error!");
FirebaseCrash.report(exception);

// or

try {
    int a = 2 / 0;
} catch (Exception e) {
    FirebaseCrash.report(e);
}

Optionally, you can report custom logs by calling log() method.

FirebaseCrash.log("Button clicked!");

You can look at reports in Firebase console, section Crash reporting.

comments powered by Disqus