Applications that are buggy can make your user unhappy and they might uninstall your app. Apps can generate a lot of crashes and manually tracking them is time-consuming. Firebase Crashlytics helps you in collecting these crashes, analyzing them, and organizing the crash reports. It also helps in setting the priority of these crashes so you can fix them as per the priority. With Firebase Crashlytics you can see the crashes at a glance on a dashboard view.
Setup Firebase Project
Go To Firebase console and create a new project
Write your project name, accept terms & conditions and click on continue
Choose your Google account and create the project.
Install react-native dependencies for Firebase Crashlytics
Install the following react native firebase crashlytics dependencies
yarn add @react-native-firebase/app
Install the Crashlytics module
yarn add @react-native-firebase/crashlytics
If you’re developing your app using iOS, run this command
cd ios/ && pod install
Configure Android with Firebase
- Click on the android icon on the firebase dashboard to setup application Write your app name and register
2. Download the google-services.json file and put it on your —
projectname/android/app — folder.
3. Add google-service dependency in your
4. Add firebase crashlytics plugin dependency in your android/build.gradle
5. Apply the com.google.firebase.crashlytics plugin by adding the following to the top of your
Once the above steps have been completed, rebuild your Android project:
npx react-native run-android
Configure iOS with Firebase
- Click on the iOS icon on the firebase dashboard to setup application Write your app name and register
- Download the GoogleService-Info.plist file and move it into your ios project directory
- Make sure to import firebase and firebase crashlytics module is imported in App.Delegate.m.
- Also, configure the firebase module in App.Delegate.m inside didFinishLaunchingWithOptions
Time to see crashlytics in action
First, import the module into your file.
Crashlytics provide us several useful methods that we can use to track app errors easily. Some are listed below.
We can use the log method throughout our app to accumulate extra context for possible crashes that can happen.
I have placed this method in my component mounting to log app mounted phase on the firebase console.
Now move to the crashlytics window, under the events section you will see the log appearing.
To test Crashlytics we can use the crash method to crash the app forcefully.
As an example, I have forcefully crashed my testing app on the login method.
On login, my testing app crashed, firebase crashlytics collect this crash and will send this to the firebase console, so If I open my firebase console, under the crashlytics window I can see the crash reports.
setCrashlyticsCollectionEnabled To stop collecting the crashlytics, we can use setCrashlyticsCollectionEnabled to disable the crashlytics.