DEV Community

Sachin-senapati
Sachin-senapati

Posted on

πŸ”₯ Integrate Firebase Crashlytics in React Native (Expo)

πŸ’‘ What is Firebase Crashlytics?

Firebase Crashlytics is a real-time crash reporting tool that helps developers:

  • πŸ“‰ Track and diagnose app crashes and errors
  • πŸ” Understand the root causes using detailed stack traces
  • πŸ“Š Monitor the stability of your app in production

It's essential for maintaining a stable and reliable user experience post-deployment.


❓ Why Should You Use Crashlytics?

🚫 Without Crashlytics:

  • You won't know if your app crashes in production
  • Users are unlikely to report every crash manually

βœ… With Crashlytics:

  • Get real-time crash reports
  • See detailed logs, device info, and contextual data
  • Prioritize and fix high-impact issues quickly

πŸ› οΈ Step-by-Step Integration Guide


βœ… 1. Create a Firebase Project

  1. Go to Firebase Console and sign in or create an account.

  2. Click on "Get started by setting up a Firebase project"
    Create project

  3. Enter your project name β†’ Click Continue

    Project Name

  4. Allow Analytics

    Allow analytics

  5. Enable Google Analytics (optional) β†’ Accept terms

    Enable Analytics

  6. Click "Create Project"

    Create Project

  7. Wait for project creation

    After Creation

  8. Click "Continue" to see the project overview

    Project overview


πŸ“± 2. Register Your App in Firebase Console

Click on the Android or iOS icon to add your app.

πŸ”Ή For Android:

  • Enter your Package Name (e.g., com.mycorp.myapp) Android package name

πŸ”Ή For iOS:

  • Enter your Bundle ID (must match the ID in Xcode) iOS bundle ID

πŸ“₯ Download Configuration Files:

  • Android: google-services.json
  • iOS: GoogleService-Info.plist

πŸ’‘ To add another platform later, click "Add App" in Firebase Console and repeat the steps.


βš›οΈ 3. Configure React Native App (Expo + EAS)

Install Firebase and Crashlytics Dependencies

npx expo install @react-native-firebase/app
npx expo install @react-native-firebase/crashlytics
Enter fullscreen mode Exit fullscreen mode

🧩 4. Update app.json or app.config.js

Add Firebase configuration and plugins:

{
  "expo": {
    "android": {
      "googleServicesFile": "./google-services.json",
      "package": "com.mycorp.myapp"
    },
    "ios": {
      "googleServicesFile": "./GoogleService-Info.plist",
      "bundleIdentifier": "com.mycorp.myapp"
    },
    "plugins": [
      "@react-native-firebase/app",
      "@react-native-firebase/auth",
      "@react-native-firebase/crashlytics",
      [
        "expo-build-properties",
        {
          "ios": {
            "useFrameworks": "static"
          }
        }
      ]
    ]
  }
}
Enter fullscreen mode Exit fullscreen mode

βš™οΈ 5. Prebuild Native Code

Run this to generate native iOS and Android code:

npx expo prebuild --clean
Enter fullscreen mode Exit fullscreen mode

πŸ” Always do this after adding or removing native packages like Firebase modules.

πŸš€ 6. Build or Run the App

Using EAS Build:

eas build --platform android
eas build --platform ios
Enter fullscreen mode Exit fullscreen mode

Or Run Locally:

npx expo run:android
npx expo run:ios
Enter fullscreen mode Exit fullscreen mode

πŸ§ͺ 7. Test Crashlytics Integration

To test a crash, add this to your code:

import crashlytics from '@react-native-firebase/crashlytics';

crashlytics().log('Manually testing crash');
crashlytics().crash(); // This will cause a test crash

Enter fullscreen mode Exit fullscreen mode

⚠️ Important Notes & Limitations

🚫 Crashlytics does NOT work in Expo Go

  • Expo Go does not support native Firebase modules like Crashlytics.
  • You must use EAS Build, a custom development client, or run a local native build to use Crashlytics.

Top comments (1)

Collapse
 
rudresh1 profile image
rudresh1

πŸ‘