Catch up on everything announced at Firebase Summit, and learn how Firebase can help you accelerate app development and run your app with confidence. Learn More

Get started with Firebase Crashlytics

This quickstart describes how to set up Firebase Crashlytics in your app with the Firebase Crashlytics SDK so that you can get comprehensive crash reports in the Firebase console. With Crashlytics for Android, you get reports for crashes, non-fatal errors, and "Application Not Responding" (ANR) errors.

Setting up Crashlytics requires tasks both in the Firebase console and your IDE (like adding a Firebase configuration file and the Crashlytics SDK). To finish setup, you'll need to force a test crash to send your first crash report to Firebase.

Before you begin

  1. If you haven't already, add Firebase to your Android project. If you don't have an Android app, you can download a sample app.

  2. Recommended: To get features like crash-free users, breadcrumb logs, and velocity alerts, you need to enable Google Analytics in your Firebase project.

    • If your existing Firebase project doesn't have Google Analytics enabled, you can enable Google Analytics from the Integrations tab of your > Project settings in the Firebase console.

    • If you're creating a new Firebase project, enable Google Analytics during the project creation workflow.

Step 1: Add the Crashlytics SDK to your app

In your module (app-level) Gradle file (usually <project>/<app-module>/build.gradle), add the dependency for the Crashlytics Android library. We recommend using the Firebase Android BoM to control library versioning.

For an optimal experience with Crashlytics, we recommend enabling Google Analytics in your Firebase project and adding the Firebase SDK for Google Analytics to your app.

Java

dependencies {
    // Import the BoM for the Firebase platform
    implementation platform('com.google.firebase:firebase-bom:31.1.0')

    // Add the dependencies for the Crashlytics and Analytics libraries
    // When using the BoM, you don't specify versions in Firebase library dependencies
    implementation 'com.google.firebase:firebase-crashlytics'
    implementation 'com.google.firebase:firebase-analytics'
}

By using the Firebase Android BoM, your app will always use compatible versions of Firebase Android libraries.

(Alternative) Add Firebase library dependencies without using the BoM

If you choose not to use the Firebase BoM, you must specify each Firebase library version in its dependency line.

Note that if you use multiple Firebase libraries in your app, we strongly recommend using the BoM to manage library versions, which ensures that all versions are compatible.

dependencies {
    // Add the dependencies for the Crashlytics and Analytics libraries
    // When NOT using the BoM, you must specify versions in Firebase library dependencies
    implementation 'com.google.firebase:firebase-crashlytics:18.3.2'
    implementation 'com.google.firebase:firebase-analytics:21.2.0'
}

Kotlin+KTX

dependencies {
    // Import the BoM for the Firebase platform
    implementation platform('com.google.firebase:firebase-bom:31.1.0')

    // Add the dependencies for the Crashlytics and Analytics libraries
    // When using the BoM, you don't specify versions in Firebase library dependencies
    implementation 'com.google.firebase:firebase-crashlytics-ktx'
    implementation 'com.google.firebase:firebase-analytics-ktx'
}

By using the Firebase Android BoM, your app will always use compatible versions of Firebase Android libraries.

(Alternative) Add Firebase library dependencies without using the BoM

If you choose not to use the Firebase BoM, you must specify each Firebase library version in its dependency line.

Note that if you use multiple Firebase libraries in your app, we strongly recommend using the BoM to manage library versions, which ensures that all versions are compatible.

dependencies {
    // Add the dependencies for the Crashlytics and Analytics libraries
    // When NOT using the BoM, you must specify versions in Firebase library dependencies
    implementation 'com.google.firebase:firebase-crashlytics-ktx:18.3.2'
    implementation 'com.google.firebase:firebase-analytics-ktx:21.2.0'
}

Step 2: Add the Crashlytics Gradle plugin to your app

  1. In your root-level (project-level) Gradle file (<project>/build.gradle), add the Crashlytics Gradle plugin as a buildscript dependency:

    buildscript {
        repositories {
          // Make sure that you have the following two repositories
          google()  // Google's Maven repository
          mavenCentral()  // Maven Central repository
        }
    
        dependencies {
            ...
            classpath 'com.android.tools.build:gradle:7.2.0'
    
            // Make sure that you have the Google services Gradle plugin dependency
            classpath 'com.google.gms:google-services:4.3.14'
    
            // Add the dependency for the Crashlytics Gradle plugin
            classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.2'
        }
    }
  2. In your module (app-level) Gradle file (usually <project>/<app-module>/build.gradle), add the Crashlytics Gradle plugin:

    plugins {
        id 'com.android.application'
    
        // Make sure that you have the Google services Gradle plugin
        id 'com.google.gms.google-services'
    
        // Add the Crashlytics Gradle plugin
        id 'com.google.firebase.crashlytics'
        ...
    }

Step 3: Force a test crash to finish setup

To finish setting up Crashlytics and see initial data in the Crashlytics dashboard of the Firebase console, you need to force a test crash.

  1. Add code to your app that you can use to force a test crash.

    You can use the following code in your app's MainActivity to add a button to your app that, when pressed, causes a crash. The button is labeled "Test Crash".

    Java

    Button crashButton = new Button(this);
    crashButton.setText("Test Crash");
    crashButton.setOnClickListener(new View.OnClickListener() {
       public void onClick(View view) {
           throw new RuntimeException("Test Crash"); // Force a crash
       }
    });
    
    addContentView(crashButton, new ViewGroup.LayoutParams(
           ViewGroup.LayoutParams.MATCH_PARENT,
           ViewGroup.LayoutParams.WRAP_CONTENT));
    

    Kotlin+KTX

    val crashButton = Button(this)
    crashButton.text = "Test Crash"
    crashButton.setOnClickListener {
       throw RuntimeException("Test Crash") // Force a crash
    }
    
    addContentView(crashButton, ViewGroup.LayoutParams(
           ViewGroup.LayoutParams.MATCH_PARENT,
           ViewGroup.LayoutParams.WRAP_CONTENT))
    
  2. Build and run your app.

  3. Force the test crash in order to send your app's first crash report:

    1. Open your app from your test device or emulator.

    2. In your app, press the "Test Crash" button that you added using the code above.

    3. After your app crashes, restart it so that your app can send the crash report to Firebase.

  4. Go to the Crashlytics dashboard of the Firebase console to see your test crash.

    If you've refreshed the console and you're still not seeing the test crash after five minutes, enable debug logging to see if your app is sending crash reports.


And that's it! Crashlytics is now monitoring your app for crashes, non-fatal errors, and ANRs. Visit the Crashlytics dashboard to view and investigate all your reports and statistics.

Next steps

  • Integrate with Google Play so that you can filter your Android app's crash reports by Google Play track directly in the Crashlytics dashboard. This allows you to better focus your dashboard on specific builds.
  • View stack traces and crash statistics directly alongside your code with the App Quality Insights window in Android Studio. Using this tool, you don't need to jump back and forth between the Crashlytics dashboard and the IDE to start addressing top issues.