Add Firebase to Your Android Project


  • A device running:
    • Android 4.1 (API level 16, Jelly Bean) or later
    • Google Play services 15.0.0 or later
  • The latest version of Android Studio

If you don't have an Android Studio project already, you can download one of our quickstart samples if you just want to try a Firebase feature. If you're using a quickstart, remember to get the application ID from the build.gradle file in your project's module folder (typically app/), as you'll need this package name for the next step.

Add Firebase to your app

If you're using Android Studio version 2.2 or later, the Firebase Assistant is the simplest way to connect your app to Firebase. The Assistant can connect your existing project or create a new one for you with all the necessary gradle dependencies.

If you're using an older version of Android Studio or have a more complex project configuration, you can still manually add Firebase to your app.

Use the Firebase Assistant

To open the Firebase Assistant in Android Studio:

  • Click Tools > Firebase to open the Assistant window.
  • Click to expand one of the listed features (for example, Analytics), then click the provided tutorial link (for example, Log an Analytics event).
  • Click the Connect to Firebase button to connect to Firebase and add the necessary code to your app.

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

Manually add Firebase

It's time to add Firebase to your app. To do this you'll need a Firebase project and a Firebase configuration file for your app.

To create a Firebase project:

  1. Go to the Firebase console.

  2. Click Add project, then select or enter a Project name.

    • If you have an existing Google project associated with your app, select the project from the Project name dropdown menu.
    • If you don't have an existing Google project, enter a new Project name.
  3. (Optional) Edit the Project ID.

    Firebase automatically assigns a unique ID to your Firebase project. This identifier displays in publicly visible Firebase services, for example:

    • Default Realtime Database URL —
    • Default Cloud Storage bucket name —
    • Default Hosting subdomain —
  4. Follow the remaining setup steps in the Firebase console, then click Create project (or Add Firebase, if you're using an existing Google project).

Firebase automatically provisions resources for your Firebase project. The process typically takes a few minutes. When the process completes, you'll be taken to the overview page for your Firebase project in the Firebase console.

Now that you have a project, you can add your Android app to it:

  1. Click Add Firebase to your Android app and follow the setup steps. If you're importing an existing Google project, this may happen automatically and you can just download the config file.

  2. When prompted, enter your app's package name. It's important to enter the package name your app is using; this can only be set when you add the app to your Firebase project.

  3. Add the Firebase Android configuration file to your app:

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

      You can download your Firebase Android config file again at any time.

    2. Move your config file into the same directory as your root-level build.gradle file.

  4. After you add the initialization code, run your app to send verification to the Firebase console that you've successfully installed Firebase.

Add the SDK

If you would like to integrate the Firebase libraries into one of your own projects, you need to perform a few basic tasks to prepare your Android Studio project. You may have already done this as part of adding Firebase to your app.

First, add rules to your root-level build.gradle file, to include the google-services plugin and the Google's Maven repository:

buildscript {
    // ...
    dependencies {
        // ...
        classpath '' // google-services plugin

allprojects {
    // ...
    repositories {
        google() // Google's Maven repository
        // ...

Then, in your module Gradle file (usually the app/build.gradle), add the apply plugin line at the bottom of the file to enable the Gradle plugin:

apply plugin: ''

android {
  // ...

dependencies {
  // ...
  implementation ''

  // Getting a "Could not find" error? Make sure you have
  // added the Google maven respository to your root build.gradle

apply plugin: ''

You should also add the dependencies for the Firebase SDKs you want to use. We recommend starting with, which provides Google Analytics for Firebase functionality. See the list of available libraries.

Available libraries

The following libraries are available for the various Firebase features.

Gradle Dependency Line Service Analytics Realtime Database Cloud Firestore Storage Crashlytics Authentication Cloud Messaging Remote Config Invites and Dynamic Links AdMob App Indexing Performance Monitoring Cloud Functions for Firebase Client SDK ML Kit (Vision) ML Kit (Custom Model) ML Kit (Natural Language) ML Kit (Natural Language ID Model)

Next steps

Learn about Firebase:

Add Firebase features to your app:

Send feedback about...

Need help? Visit our support page.