These steps assume:
@react-native-firebase/appand@react-native-firebase/crashlyticsare already installed (see Crashlytics usage).- You are configuring a React Native CLI Android project. Expo projects should add the
@react-native-firebase/crashlyticsconfig plugin, which covers steps 2 and 3 below (see the Expo note below and Expo). - You can edit
android/build.gradleandandroid/app/build.gradle, then rebuild Android. - Your project meets the minimum versions that the Firebase Android NDK guide lists as prerequisites: Gradle 8.0, Android Gradle plugin 8.1.0 and Google services Gradle plugin 4.4.1.
If you're migrating from Fabric, make sure you remove the
fabric.propertiesfile from your Android project. If you do not do this you will not receive crash reports on the Firebase console.
If you're using Expo, make sure to add the
@react-native-firebase/crashlyticsconfig plugin to yourapp.jsonorapp.config.js. The plugin covers only step 2 (the Crashlytics Gradle plugin dependency inandroid/build.gradle) and step 3 (applying the plugin inandroid/app/build.gradle). It does not add the Google repository (step 1) or the optional NDK block (step 4), so follow them yourself below; they need a nativeandroid/folder, whichnpx expo prebuildgenerates in an Expo project. Because that folder is regenerated bynpx expo prebuild --cleanand by EAS Build, edits made directly in it may not persist, so a workflow that regenerates it needs those changes made another way (for example a custom config plugin). For instructions on adding the plugin, view the Expo installation section.
These steps are required. If you do not add them, your app will most likely crash at startup with:
"The Crashlytics build ID is missing. This occurs when Crashlytics tooling is absent from your app's build configuration. Please review Crashlytics onboarding instructions and ensure you have a valid Crashlytics account."
Add the Google Maven repository inside the existing buildscript.repositories block of android/build.gradle:
// File: android/build.gradle. Step 1 of 5 (inside existing buildscript.repositories).
buildscript {
repositories {
google()
}
}Add the Crashlytics Gradle plugin dependency line inside the existing buildscript.dependencies block of android/build.gradle:
// File: android/build.gradle. Step 2 of 5 (inside existing buildscript.dependencies).
buildscript {
dependencies {
classpath 'com.google.firebase:firebase-crashlytics-gradle:3.0.8'
}
}Apply the com.google.firebase.crashlytics plugin near the top of android/app/build.gradle, after the Android application and Google Services plugins:
// File: android/app/build.gradle. Step 3 of 5 (top of file, after google-services).
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'Crashlytics NDK reporting allows you to capture Native Development Kit crashes, which are crashes in native C and C++ code. The React Native Firebase Android module already includes the Crashlytics NDK library. This step enables the upload of native symbols, which Crashlytics needs to show readable native stack traces. The Firebase Android NDK guide covers the details.
Add a firebaseCrashlytics block inside the existing android.buildTypes.release block of android/app/build.gradle:
// File: android/app/build.gradle. Step 4 of 5 (optional, inside android.buildTypes.release).
android {
buildTypes {
release {
firebaseCrashlytics {
nativeSymbolUploadEnabled true
unstrippedNativeLibsDir 'build/intermediates/merged_native_libs/release/out/lib'
}
}
}
}With nativeSymbolUploadEnabled set to true, the Crashlytics Gradle plugin adds an uploadCrashlyticsSymbolFile<BuildVariant> task, for example uploadCrashlyticsSymbolFileRelease. For method names to appear in native stack traces, run that task after each build of your native libraries, for example ./gradlew app:assembleRelease app:uploadCrashlyticsSymbolFileRelease from the android folder.
Once the above steps have been completed, rebuild your Android project from the project root:
# Project root. Step 5 of 5 (after Gradle plugin configuration).
npx react-native run-android
Core / App