Firebase Crash Report
As you know, Google launch Firebase, firebase is a cloud service provider which provides you the tools and infrastructure to build better and effective apps.There are many feature in Firebase:
1. Firebase Analytics.
2. Firebase Cloud Messaging.
3. Firebase Test Lab.
4. Firebase Real time database.
5. Firebase Notifications, Dynamic Links, App Indexing, AdWords, Firebase Invites etc.
Firebase crash Reporting will report errors in your application. Errors are grouped into issues based on having stack traces. If you want to report custom error message you can do this.
How to use?
Firebase works with new google play services 9.0 (or later) and use it in Android studio.
Add Firebase to your app
- Click on Create New Project or you can import google project.
- Now within your app click on Add firebase to your Android app.
you'll prompted to add your package name, and also to download the google-services.json file. you have to add this file in app directory.
2. Add the SDK to your app
It is very simple to setup firebase in your app. Follow the below step:
First, include the following lines to your root-level build.gradle
file:
buildscript {
// ...
dependencies {
// ...
classpath 'com.google.gms:google-services:3.0.0'
}
}
And then at your app-module’s build.gradle
file, apply the google services plugin at the bottom of the file.
Your build.gradle
should look like this:
apply plugin: 'com.android.application'
android {
// ...
}
dependencies {
// ...
compile 'com.google.firebase:firebase-crash:9.4.0'
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
First, include the following lines to your root-level
build.gradle
file:buildscript {
// ...
dependencies {
// ...
classpath 'com.google.gms:google-services:3.0.0'
}
}
build.gradle
file, apply the google services plugin at the bottom of the file.Your
build.gradle
should look like this:apply plugin: 'com.android.application'
android {
// ...
}
dependencies {
// ...
compile 'com.google.firebase:firebase-crash:9.4.0'
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
Reporting crashes
Firebase Crash reporting automatically reports fatal errors (unhandled exceptions) once the dependency has been added and configured.
It requires NO line of code.
Report non-fatal exceptions.
To check the firebase crash report without crashes,Firebase allows you to manually report handled non-fatal (i.e exceptions that do not cause app crash). It’s always good to report any errors that happen, whether or not they cause a crash
FirebaseCrash.report(new Exception("My first Firebase non-fatal error on Android"));
After a few minutes (it now takes about 1minutes t0 1 hours), the crash will appear on the console dashboard looking like:
FirebaseCrash.report(new Exception("My first Firebase non-fatal error on Android"));
There are other interesting things to do with Firebase crash reporting.
If you want to create custom logs for events in the reports. Usually, when you get a crash in your app, the next thing you want to find out is, what the user was trying to do right? Well, creating logs make that easy to do. You can create a log using a line like:
FirebaseCrash.log("MainActivity started");
You can also make that log show on your logcat, use:
FirebaseCrash.logcat(Log.DEBUG, "TAG", "MainActivity started");
If you want to create custom logs for events in the reports. Usually, when you get a crash in your app, the next thing you want to find out is, what the user was trying to do right? Well, creating logs make that easy to do. You can create a log using a line like:
You can also make that log show on your logcat, use:
FirebaseCrash.logcat(Log.DEBUG, "TAG", "MainActivity started");
0 comments:
Post a Comment