The new Firebase Crash Reporting

Gabriele Mariotti
3 min readMay 20, 2016

--

Firebase 3.0 introduces a lot of new features.
One of these is the integration with the Google Play Services (v 9+).

I’ve tried to use the new Crash Reporting to creates detailed reports of the errors in my app ( Do you kwow Fabric/Crashlytics ?).

Here the steps to follow:

Prerequisites:

Create a Firebase project:

  • Create a Firebase project in the Firebase console
  • Click Add Firebase to your Android app and follow the setup steps (very simple…just add your package name)
  • Download the google-services.json file and copy this into your project’s module folder

Add the Firebase libraries:

In your root-level build.gradle file include the google-services plugin:

buildscript {
// ...
dependencies {
// ...
classpath 'com.google.gms:google-services:3.0.0'
}
}

Then, in your module Gradle file ,

  • add the apply plugin line at the bottom of the file to enable the Gradle plugin
  • add the firebase dependency
apply plugin: 'com.android.application'android {
// ...
}
dependencies {
// ...
compile 'com.google.firebase:firebase-crash:9.0.0'
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'

Use your app:

Firebase Crash Reporting automatically generates reports for fatal errors (or uncaught exceptions).

Pay attention to this step:

  • Crash Reporting is currently in beta release
  • Errors take up to 20 minutes to show up in the Crash Reporting console.

Just to try I used this line to generate a crash:

FirebaseCrash.report(new Exception("My first Android non-fatal error"));

You can check in the log when FirebaseCrash initialized the module:

05–20 08:57:24.442 D/FirebaseCrashApiImpl: FirebaseCrash reporting API initialized
05–20 08:57:24.442 I/FirebaseCrash: FirebaseCrash reporting initialized com.google.firebase.crash.internal.zzg@3333d325
05–20 08:57:24.442 D/FirebaseApp: Initialized class com.google.firebase.crash.FirebaseCrash.

And then when it sent the exception:

05–20 08:57:47.052 D/FirebaseCrashApiImpl: throwable java.lang.Exception: My first Android non-fatal error
05–20 08:58:18.822 D/FirebaseCrashSenderServiceImpl: Response code: 200
05–20 08:58:18.822 D/FirebaseCrashSenderServiceImpl: Report sent

Now you have to wait a few minutes to check the exception in the crash console.

Here the issue in console:

More details about the issue:

There is a nice feature in the dashboard: the cluster.
A cluster is a group of errors that have similar stack traces. Each row in the table below represents a cluster.

Here a simple example using different exceptions:

As you can see in the picture (last line) FirebaseCrash is able to get the OutOfMemoryError and it sends the crash to the console.

If you want to customize something, for example if you would like to disable the crash in a BuildType there isn’t documentation to achieve it.

I’d expect something like:

FirebaseCrash.enable(true);

but… pay attention, this method doesn’t exist!

--

--