Firebase – Crash Reporting
- Crash Reporting seems to be an important factor nowadays, as we are less determined about what error can occur on which device model or which Android Version. There are few crash reporting tools available in the market, like ACRA, Fabrics Crashalytics, etc. But this Firebase is something different which made me to write this blog for getting started with it.
- Firebase Crash Reporting is a comprehensive tool to receive detailed information about the Crash.
Why to switch over it ?
Yes, this is the question I always ask, which boosts me to get started with. So, here are some strong reasons:
- You can prioritize the reports by Frequency of crash
- You can prioritize the reports by Impact
- You get detailed report that includes:
- device characteristics
- device circumstances
- stack trace and much more
- You can collect crash report even when app is offline..!!
- Android Studio 1.5 or above
- Google Play Services 9.0.2 or above.
Add Firebase to your app
- Go to Firebase console and click on â€œCREATE NEW PROJECTâ€. Fill the â€œProject Nameâ€ and Select Country, then click on â€œCREATE PROJECTâ€
- Click on â€œAdd Firebase to your Android appâ€
- Enter Package name and Debug signing certificate SHA-1(Optional) and click on â€œAdd appâ€ button
- Google-services.json file will be downloaded. Go to Android Studio and Switch to the Project view in Android Studio to see your project root directory. Move the google-services.json file you just downloaded into your Android app module root directory.
- The Google services plugin for Gradle loads the google-services.json file you just downloaded. Modify your build.gradle files to use the plugin.
- Add the following lines, to your Project-level build.gradle (/build.gradle):
// Add this line
- Add the following lines to the bottom of your App-level build.gradle:
apply plugin: ‘com.google.gms.google-services’
- Add the following dependencies, to your App-level build.gradle
- Finally, press “Sync now”.
No code at all..!!! I am not kidding.. 🙂 Firebase Crash Reporting automatically generates reports for errors. So, just sit back and relax!
Still if you want you can generate report for testing purpose. Add below line to your activity:
FirebaseCrash.report(new Exception(“My first Firebase crash report.”));
And run the app.
According to the Firebase article:
Errors take up to 20 minutes to show up in the Crash Reporting console. Check back to see your report there.
To see the report, Go to Firebase console, Select Your Project and on the Left Side Menu, Click on Crash.
You will see the report as below:
Important Points to remember
Apart from Firebase.report(Exception exception), you can also play with other features like.
- FirebaseCrash.log(String message): Enables a smart way to log. It will not be shown in Android Monitor Logcat, but it will appear in Crash Report.
- FirebaseCrash.logcat(Log.XXX, String tag, String message): yet another way to log. This log will appear in both Android Monitor Logcat and Crash Report.
Now you see, integrating crash reporting is become now so easy. Cool, now get your hands on it. We have used firebase crash reporting in some of our applications and We are really impressed with the detailing of the reports. Though it’s in beta, you should try!
Hope you enjoyed learning Firebase Crash Reporting. Happy Firebasing 🙂