Add Firebase to your Android project

Prerequisites

  • Install or update Android Studio to its latest version.

  • Make sure that your project meets these requirements:

    • Targets API level 19 (KitKat) or higher
    • Uses Android 4.4 or higher
    • Uses Jetpack (AndroidX), which includes meeting these version requirements:
      • com.android.tools.build:gradle v7.3.0 or later
      • compileSdkVersion 28 or later
  • Set up a physical device or use an emulator to run your app.
    Note that Firebase SDKs with a dependency on Google Play services require the device or emulator to have Google Play services installed.

  • Sign into Firebase using your Google account.

If you don't already have an Android project and just want to try out a Firebase product, you can download one of our quickstart samples.


You can connect your Android app to Firebase using one of the following options:

  • Option 1: (recommended) Use the Firebase console setup workflow.
  • Option 2: Use the Android Studio Firebase Assistant (may require additional configuration).



Option 1: Add Firebase using the Firebase console

Adding Firebase to your app involves tasks both in the Firebase console and in your open Android project (for example, you download Firebase config files from the console, then move them into your Android project).

Step 1: Create a Firebase project

Before you can add Firebase to your Android app, you need to create a Firebase project to connect to your Android app. Visit Understand Firebase Projects to learn more about Firebase projects.

Step 2: Register your app with Firebase

To use Firebase in your Android app, you need to register your app with your Firebase project. Registering your app is often called "adding" your app to your project.

  1. Go to the Firebase console.

  2. In the center of the project overview page, click the Android icon () or Add app to launch the setup workflow.

  3. Enter your app's package name in the Android package name field.

  4. (Optional) Enter other app information: App nickname and Debug signing certificate SHA-1.

  5. Click Register app.

Step 3: Add a Firebase configuration file

  1. Download and then add the Firebase Android configuration file (google-services.json) to your app:

    1. Click Download google-services.json to obtain your Firebase Android config file.

    2. Move your config file into the module (app-level) root directory of your app.

  2. To make the values in your google-services.json config file accessible to Firebase SDKs, you need the Google services Gradle plugin (google-services).

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

      Kotlin

      plugins {
        id("com.android.application") version "7.3.0" apply false
        // ...
      
        // Add the dependency for the Google services Gradle plugin
        id("com.google.gms.google-services") version "4.4.1" apply false
      }
      

      Groovy

      plugins {
        id 'com.android.application' version '7.3.0' apply false
        // ...
      
        // Add the dependency for the Google services Gradle plugin
        id 'com.google.gms.google-services' version '4.4.1' apply false
      }
      
    2. In your module (app-level) Gradle file (usually <project>/<app-module>/build.gradle.kts or <project>/<app-module>/build.gradle), add the Google services plugin:

      Kotlin

      plugins {
        id("com.android.application")
      
        // Add the Google services Gradle plugin
        id("com.google.gms.google-services")
        // ...
      }
      

      Groovy

      plugins {
        id 'com.android.application'
      
        // Add the Google services Gradle plugin
        id 'com.google.gms.google-services'
        // ...
      }
      

Step 4: Add Firebase SDKs to your app

  1. In your module (app-level) Gradle file (usually <project>/<app-module>/build.gradle.kts or <project>/<app-module>/build.gradle), add the dependencies for the Firebase products that you want to use in your app. We recommend using the Firebase Android BoM to control library versioning.

    Analytics enabled

    dependencies {
      // ...
    
      // Import the Firebase BoM
      implementation(platform("com.google.firebase:firebase-bom:32.7.4"))
    
      // When using the BoM, you don't specify versions in Firebase library dependencies
    
      // Add the dependency for the Firebase SDK for Google Analytics
      implementation("com.google.firebase:firebase-analytics")
    
      // TODO: Add the dependencies for any other Firebase products you want to use
      // See https://firebase.google.com/docs/android/setup#available-libraries
      // For example, add the dependencies for Firebase Authentication and Cloud Firestore
      implementation("com.google.firebase:firebase-auth")
      implementation("com.google.firebase:firebase-firestore")
    }
    

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

    Looking for a Kotlin-specific library module? Starting in October 2023 (Firebase BoM 32.5.0), both Kotlin and Java developers can depend on the main library module (for details, see the FAQ about this initiative).

    Analytics not enabled

    dependencies {
      // ...
    
      // Import the Firebase BoM
      implementation(platform("com.google.firebase:firebase-bom:32.7.4"))
    
      // When using the BoM, you don't specify versions in Firebase library dependencies
    
      // TODO: Add the dependencies for Firebase products you want to use
      // See https://firebase.google.com/docs/android/setup#available-libraries
      // For example, add the dependencies for Firebase Authentication and Cloud Firestore
      implementation("com.google.firebase:firebase-auth")
      implementation("com.google.firebase:firebase-firestore")
    }
    

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

    Looking for a Kotlin-specific library module? Starting in October 2023 (Firebase BoM 32.5.0), both Kotlin and Java developers can depend on the main library module (for details, see the FAQ about this initiative).

  2. After adding the dependencies for the products you want to use, sync your Android project with Gradle files.

That's it! You can skip ahead to check out the recommended next steps.

If you're having trouble getting set up, though, visit the Android troubleshooting & FAQ.



Option 2: Add Firebase using the Firebase Assistant

The Firebase Assistant registers your app with a Firebase project and adds the necessary Firebase files, plugins, and dependencies to your Android project — all from within Android Studio!

  1. Open your Android project in Android Studio, then make sure that you're using the latest versions of Android Studio and the Firebase Assistant:

    • Windows / Linux: Help > Check for updates
    • macOS: Android Studio > Check for updates
  2. Open the Firebase Assistant: Tools > Firebase.

  3. In the Assistant pane, choose a Firebase product to add to your app. Expand its section, then click the tutorial link (for example, Analytics > Log an Analytics event).

    1. Click Connect to Firebase to connect your Android project with Firebase.

    2. Click the button to add a desired Firebase product (for example, Add Analytics to your app).

  4. Sync your app to ensure that all dependencies have the necessary versions.

  5. In the Assistant pane, follow the remaining setup instructions for your selected Firebase product.

  6. Add as many other Firebase products as you'd like via the Firebase Assistant!

That's it! Make sure to check out the recommended next steps.

If you're having trouble getting set up, though, visit the Android troubleshooting & FAQ.



Available libraries

This section lists the Firebase products supported for Android and their Gradle dependencies. Learn more about these Firebase Android libraries:

Note that when using the Firebase Android BoM, you don't specify individual library versions when you declare Firebase library dependencies in your Gradle build configuration file.

Service or Product Gradle dependency Latest
version
Add Analytics?
Firebase Android BoM
(Bill of Materials)
com.google.firebase:firebase-bom

The latest Firebase BoM version contains the latest versions of each Firebase Android library. To learn which library versions are mapped to a specific BoM version, review the release notes for that BoM version.

32.7.4
AdMob com.google.android.gms:play-services-ads 23.0.0
Analytics com.google.firebase:firebase-analytics 21.5.1
App Check custom provider com.google.firebase:firebase-appcheck 17.1.2
App Check debug provider com.google.firebase:firebase-appcheck-debug 17.1.2
App Check Play Integrity provider com.google.firebase:firebase-appcheck-playintegrity 17.1.2
App Distribution com.google.firebase:firebase-appdistribution 16.0.0-beta12
App Distribution API com.google.firebase:firebase-appdistribution-api 16.0.0-beta12
App Distribution plugin com.google.firebase:firebase-appdistribution-gradle 4.2.0
Authentication com.google.firebase:firebase-auth 22.3.1
Cloud Firestore com.google.firebase:firebase-firestore 24.10.3
Cloud Functions for Firebase Client SDK com.google.firebase:firebase-functions 20.4.0
Cloud Messaging com.google.firebase:firebase-messaging 23.4.1
Cloud Storage com.google.firebase:firebase-storage 20.3.0
Crashlytics com.google.firebase:firebase-crashlytics 18.6.2
Crashlytics NDK com.google.firebase:firebase-crashlytics-ndk 18.6.2
Crashlytics plugin com.google.firebase:firebase-crashlytics-gradle 2.9.9
Dynamic feature module support com.google.firebase:firebase-dynamic-module-support 16.0.0-beta03
Dynamic Links com.google.firebase:firebase-dynamic-links 21.2.0
In-App Messaging com.google.firebase:firebase-inappmessaging 20.4.0
(required)
In-App Messaging Display com.google.firebase:firebase-inappmessaging-display 20.4.0
(required)
Firebase installations com.google.firebase:firebase-installations 17.2.0
Firebase ML Model Downloader API com.google.firebase:firebase-ml-modeldownloader 24.2.3
Performance Monitoring com.google.firebase:firebase-perf 20.5.2
Performance Monitoring plugin com.google.firebase:perf-plugin 1.4.2
Realtime Database com.google.firebase:firebase-database 20.3.1
Remote Config com.google.firebase:firebase-config 21.6.3
Google Play services plugin com.google.gms:google-services 4.4.1
DEPRECATED LIBRARIES
App Check SafetyNet provider com.google.firebase:firebase-appcheck-safetynet 16.1.2
App Indexing com.google.firebase:firebase-appindexing 20.0.0

Firebase KTX modules

Analytics com.google.firebase:firebase-analytics-ktx 21.5.1
App Check custom provider com.google.firebase:firebase-appcheck-ktx 17.1.2
App Distribution API com.google.firebase:firebase-appdistribution-api-ktx 16.0.0-beta12
Authentication com.google.firebase:firebase-auth-ktx 22.3.1
Cloud Firestore com.google.firebase:firebase-firestore-ktx 24.10.3
Cloud Functions for Firebase Client SDK com.google.firebase:firebase-functions-ktx 20.4.0
Cloud Messaging com.google.firebase:firebase-messaging-ktx 23.4.1
Cloud Storage com.google.firebase:firebase-storage-ktx 20.3.0
Crashlytics com.google.firebase:firebase-crashlytics-ktx 18.6.2
Dynamic Links com.google.firebase:firebase-dynamic-links-ktx 21.2.0
In-App Messaging com.google.firebase:firebase-inappmessaging-ktx 20.4.0
(required)
In-App Messaging Display com.google.firebase:firebase-inappmessaging-display-ktx 20.4.0
(required)
Firebase installations com.google.firebase:firebase-installations-ktx 17.2.0
Firebase ML Model Downloader API com.google.firebase:firebase-ml-modeldownloader-ktx 24.2.3
Performance Monitoring com.google.firebase:firebase-perf-ktx 20.5.2
Realtime Database com.google.firebase:firebase-database-ktx 20.3.1
Remote Config com.google.firebase:firebase-config-ktx 21.6.3

Firebase ML Kit libraries

Firebase ML Custom Model APIs com.google.firebase:firebase-ml-model-interpreter 22.0.4
Firebase ML Vision APIs com.google.firebase:firebase-ml-vision 24.1.0
Firebase ML: Image Labeling Model com.google.firebase:firebase-ml-vision-image-label-model 20.0.2
Firebase ML: Object Detection and Tracking Model com.google.firebase:firebase-ml-vision-object-detection-model 19.0.6
Firebase ML: Face Detection Model com.google.firebase:firebase-ml-vision-face-model 20.0.2
Firebase ML: Barcode Scanning Model com.google.firebase:firebase-ml-vision-barcode-model 16.1.2
Firebase ML: AutoML Vision Edge API com.google.firebase:firebase-ml-vision-automl 18.0.6
Firebase ML: Natural Language APIs com.google.firebase:firebase-ml-natural-language 22.0.1
Firebase ML: Language Identification Model com.google.firebase:firebase-ml-natural-language-language-id-model 20.0.8
Firebase ML: Translate Model com.google.firebase:firebase-ml-natural-language-translate-model 20.0.9
Firebase ML: Smart Reply Model com.google.firebase:firebase-ml-natural-language-smart-reply-model 20.0.8



Next steps

Add Firebase services to your app:

Learn about Firebase: