Integrate Firebase Crashlytics into Android

Integrate Firebase Crashlytics into Android

Firebase Crashlytics is a crash reporter that can be integrated into Android application. It allows tracking, collect, and organize application crashes. We can analyze crash reports in the Firebase dashboard.

In order to use the Firebase Crashlytics we need to create a Firebase project. It can be done by following these steps:

  1. Login to the Firebase Console.
  2. Click "Add project".
  3. Provide project name and click "Continue".
  4. In the next screen, make sure "Enable Google Analytics for this project" is selected. It is used by Firebase Crashlytics to compute crash-free users and other statistics.
  5. Select existing Google Analytics account or create a new account.
  6. Click "Create project".
  7. When project was created click the Android icon.
  8. Provide Android package name. It can be found in the AndroidManifest.xml file (example:
  9. Click "Register app".
  10. Download the google-service.json file and add into the app directory.
  11. Click "Next". When a new tab appears click "Next" again.
  12. Skip verification process by clicking "Skip this step".
  13. In the left-hand navigation panel click "Crashlytics".
  14. Click "Enable Crashlytics".

We need to add Google services plugin for Gradle to project-level build.gradle file. This plugin process the google-services.json file and generates resources that can be used in the code.

Also, we need to add the Crashlytics Gradle plugin.


buildscript {
    // Other configuration

    dependencies {
        // ...
        classpath ''
        classpath ''

In the module’s build.gradle file, we need to apply newly added Gradle plugins. Also, we need to add firebase-crashlytics dependency.


apply plugin: ''
// ...
apply plugin: ''
apply plugin: ''

android {
    // ...

dependencies {
    // Other dependencies
    // ...
    implementation ''

In the layout XML file we added Button which will used to simulate application crash.


<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android=""

        android:text="Make crash" />


To test application crash, we added a code that divide a number by zero.



import android.os.Bundle

class MainActivity : AppCompatActivity()
    override fun onCreate(savedInstanceState: Bundle?)
        myButton.setOnClickListener { 1 / 0 }

Now run the application and check the logcat output. If Firebase Crashlytics integration was successful, output should contain the following messages:

I/FirebaseCrashlytics: Initializing Crashlytics 17.2.1
I/FirebaseInitProvider: FirebaseApp initialization successful

Click a button and check the logcat output for a message:

D/TransportRuntime.SQLiteEventStore: Storing event with priority=HIGHEST, name=FIREBASE_CRASHLYTICS_REPORT for destination cct

Run application again. Open browser and refresh the Firebase dashboard. Now we can see the crash which occurred by pressing a button.

Firebase Crashlytics Report

Leave a Comment

Cancel reply

Your email address will not be published.