-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Crash Reporting with Firebase
Deprecated: The Firebase Crash Reporting SDK (
com.google.firebase:firebase-crash) described on this page has been replaced by Firebase Crashlytics (com.google.firebase:firebase-crashlytics). The original Crash Reporting dashboard and SDK are no longer supported — see Google's upgrade guide and the Firebase blog post It's Time to Upgrade to the New Firebase Crashlytics SDK!. For new code, follow the Crash Reporting with Crashlytics guide instead. The content below is preserved for historical context only.
Crash reporting was announced as one of the original features of the rebranded Firebase at Google I/O 2016. This guide preserves the original setup walkthrough for the standalone Firebase Crash Reporting SDK. New projects must use Firebase Crashlytics — the steps below will not produce a working integration today.
The Firebase Crash Reporting SDK's last published artifact was
com.google.firebase:firebase-crash:16.2.1. The dashboard and ingestion endpoints have since been retired (the original docs pages atfirebase.google.com/docs/crash/androidnow redirect to the Crashlytics product page). The version pins below are the values that were current when this page was written; they are documented for archival purposes only.
-
To use Firebase Crash Reporting, you had to do the basic setup for Firebase first. See the Building Data-driven Apps with Firebase guide for that setup.
-
Next was to add the Firebase Crash Android library to the app module's
build.gradlefile:
implementation 'com.google.firebase:firebase-crash:9.0.0'At the end of this step, your build.gradle file should look like this:
apply plugin: 'com.android.application'
android {
// ...
}
dependencies {
// ...
// other libraries in your project
// firebase core library
implementation 'com.google.firebase:firebase-core:9.0.0'
// firebase crash library
implementation 'com.google.firebase:firebase-crash:9.0.0'
}
// Add to the bottom of the file
apply plugin: 'com.google.gms.google-services'This step assumed the basic Firebase setup had been completed.
To send a crash report, the app added a line like:
FirebaseCrash.report(new Exception("My first Firebase non-fatal error on Android"));After a few minutes (about 20 minutes per the original Firebase Crash Reporting docs — the URL now redirects to the Crashlytics product page), the crash appeared on the console dashboard like:
The dashboard surfaced a feature called "Clusters", which grouped exceptions with similar stack traces.
Unlike many crash reporting libraries that required only a single line to initialize crash reporting throughout the app, Firebase Crash Reporting did not ship such a utility method.
Apps typically added the following block in the main application class to forward uncaught exceptions:
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler(){
@Override
public void uncaughtException(Thread thread, Throwable ex) {
FirebaseCrash.report(ex);
}
});Custom logs could also be sent. The SDK exposed:
FirebaseCrash.log("MainActivity started");A logcat-aware variant existed via FirebaseCrash.logcat():
FirebaseCrash.logcat(Log.DEBUG, "My tag", "My message");Firebase Crash Reporting accepted a ProGuard mapping upload for symbolicated stack traces. When ProGuard was enabled, a mapping.txt file was generated at:
<project-root>/<app-module>/build/outputs/mapping/<build-type>/<appname>-proguard-mapping.txt
For example: app/build/outputs/mapping/debug/app-proguard-mapping.txt.
For more on ProGuard, see the Configuring ProGuard guide.
The mapping was uploaded from the "Mapping files" tab of the dashboard:
At the time this page was written, Firebase Crash Reporting was a Beta product with active development still ongoing.
The reporter ran in a separate process, as seen below:
The original "Known issues" anchor on firebase.google.com/docs/crash/android is no longer reachable — Firebase Crashlytics is the supported successor.
This guide was originally drafted by Segun Famisa.
- Firebase Crashlytics — Get started (Android) — the supported successor
- Upgrade from Firebase Crash Reporting to Firebase Crashlytics
- Original docs at
firebase.google.com/docs/crash/androidandfirebase.google.com/docs/reference/android/com/google/firebase/crash/package-summarynow redirect to the Crashlytics product page. - Configuring ProGuard
Created by CodePath with much help from the community. Contributed content licensed under cc-wiki with attribution required. You are free to remix and reuse, as long as you attribute and use a similar license.
Finding these guides helpful?
We need help from the broader community to improve these guides, add new topics and keep the topics up-to-date. See our contribution guidelines here and our topic issues list for great ways to help out.
Check these same guides through our standalone viewer for a better browsing experience and an improved search. Follow us on twitter @codepath for access to more useful Android development resources.


