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

๐Ÿ‘