Hello Friends,
Welcome To Infinitbility!
Today, we implement react native firebase crashlytics on android.
Many Folks, stuck on firebase crashlytics setup then please read and follow all steps carefully…
What is Firebase Crashlytics
Firebase Crashlytics helps you track, prioritize, and fix stability issues that erode app quality, in realtime. Spend less time triaging and troubleshooting crashes and more time building app features that delight users.
— Firebase Crashlytics
Setup Firebase Project
Go To Firebase console and create a new project
https://console.firebase.google.com/
follow the image when you want to see the steps of creating a Firebase project.

- Click on Create A Project button to firebase journey

- Write your project name, acept term & condtion and click on continue

- Click on continue button

- choose your google account & Click on continue button

- firebase project ready to use
Configure Android with Firebase
Below steps explain, connect your firebase account to react native application.
Click on android icon on firebase dashboard for setup application
Write your app name like on below image with nick native and click on next button
Download google-services.json file and put on your — projectname/android/app — folder.
Open your android level build.gradle file and add below code
path - projectname/android/build.gradle
1// projectname/android/build.gradle23buildscript {4 ...5 repositories {6 google() // add a line when not available7 ...8 }9 dependencies {10 ...11 classpath 'com.google.gms:google-services:4.3.4' // add line12 ...13 }14}1516allprojects {17 repositories {18 ...19 google() // add a line when not available20 ...21 }22}Open your app level build.gradle file and add below code
path - projectname/android/app/build.gradle
1// projectname/android/app/build.gradle23apply plugin: "com.android.application"4apply plugin: 'com.google.gms.google-services' // add on second line below com.android.application56...78dependencies {9 ...10 implementation platform('com.google.firebase:firebase-bom:26.1.1') // add line11 implementation 'com.google.firebase:firebase-analytics' // add line12 ...13}1415...
Configure Android with Firebase Crashlytics
install react native firebase app and crashlytics module using below command
— for yarn users
1# Install & setup the app module2yarn add @react-native-firebase/app34# Install the Crashlytics module5yarn add @react-native-firebase/crashlytics— for npm users
1# Install & setup the app module2npm install @react-native-firebase/app34# Install the Crashlytics module5npm install @react-native-firebase/crashlytics
link your firebase packages
1# link @react-native-firebase/app2npx react-native link @react-native-firebase/app34# link @react-native-firebase/crashlytics5npx react-native link @react-native-firebase/crashlyticsfirebase crashlytics additional steps
— changes on projectname/android/build.gradle
1// projectname/android/build.gradle23buildscript {4 ...5 dependencies {6 ...7 classpath 'com.google.firebase:firebase-crashlytics-gradle:2.2.0'8 ...9 }10}— changes projectname/android/app/build.gradle
below code add on third line below com.google.gms.google-services
1apply plugin: 'com.google.firebase.crashlytics' // add on third line below com.google.gms.google-services2...
Enable debug crash logs
when you want to test crashes on your debug mode. create firebase.json file on root level to project.
1// <project-root>/firebase.json2{3 "react-native": {4 "crashlytics_debug_enabled": true5 }6}
Crash
Example to test crash using crashlytics
1import React, { useEffect } from 'react';2import crashlytics from '@react-native-firebase/crashlytics';34export default class crashlytics extends React.Component {56 constructor(props) {7 super(props);89 }1011 componentDidMount() {12 crashlytics().log('crash on componentDidMount.');13 crashlytics().crash()14 }15}
Error log
Example to test error log using crashlytics
1import React, { useEffect } from 'react';2import crashlytics from '@react-native-firebase/crashlytics';34export default class crashlytics extends React.Component {56 constructor(props) {7 super(props);89 }1011 componentDidMount() {12 crashlytics().log('Error on componentDidMount');13 crashlytics().recordError(error);14 }15}
Attributes
There are various methods to set attributes for the crash report, in order to provide analytics for crashes and help you review them.
1import React, { useEffect } from 'react';2import crashlytics from '@react-native-firebase/crashlytics';34export default class crashlytics extends React.Component {56 constructor(props) {7 super(props);89 }1011 async reportError() {12 crashlytics().log('Track errors.');13 await Promise.all([14 crashlytics().setAttribute('screenName', String('crashlytics')),15 crashlytics().setAttributes({16 fumctionName: 'reportError',17 errorCode: 'ER1309',18 }),19 ]);2021 crashlytics().recordError(error);2223 }24}
if you get help, please share a post on your social network
More From React Native Tutorial
Basics
- Introduction To React Native
- React Native Environment Setup using expo
- React Native Environment Setup for windows
- React Native Environment setup on Mac OS
- React Native Environment setup on linux
- React Native Project Structure
- React Native State
- React Native Props
- React Native Styling
- React Native Flexbox
- React Native Text
- React Native Textinput
- React Native Commands
- React Native ScrollView
Advances
- React Native Dark Mode
- React Native Fonts
- React Native SQLite
- React Native DatepickerAndroid
- React native ScrollView scroll to position
- How to align icon with text in react native
- React Native Image
- React Native Firebase Crashlytics
- React Native Async Storage
- React Native Share
Error & Issue Solution
- Task :app:transformDexArchiveWithDexMergerForDebug FAILED In React Native
- Expiring Daemon because JVM heap space is exhausted In React Native
- Task :app:transformNativeLibsWithMergeJniLibsForDebug FAILED In React Native
- Unable to determine the current character, it is not a string, number, array, or object in react native
- App crashed immediately after install react native video or track player
- how to delete SQLite database in android react native
- React native material dropdown twice click issue
- How to get the current route in react-navigation?
- how to disable drawer on the drawer navigation screen?
- Image not showing in ios 14 react native
- React Native image picker launchimagelibrary on second time issue
- how to open any link from react native render Html