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.

Create a Firebase project

In the Firebase console, click Add project, then
select or enter a Project name.

If you have an existing Google Cloud Platform (GCP) project, you can
select the project from the Project name dropdown menu.
Otherwise, enter a new Project name.

Step 4: Add Firebase SDKs to your app

You can add any of the
supported Firebase products to your
Android app. We recommend starting with the core Firebase SDK (com.google.firebase:firebase-core),
which provides Google Analytics for Firebase functionality.

(Optional) Add the dependencies for the other
Firebase products that you want to
use.

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

Run your app to send verification to Firebase that you've successfully
integrated Firebase.

Your device logs will display the Firebase verification that initialization
is complete. If you ran your app on an emulator that has network access, the
Firebase console notifies you that your app connection is complete.

Run your app to send verification to Firebase that you've successfully
integrated Firebase.

Your device logs will display the Firebase verification that initialization
is complete. If you ran your app on an emulator that has network access, the
Firebase console notifies you that your app connection is complete.

Control library versioning with a Firebase Bill of Materials (BoM) (experimental)

For easier library version management, consider importing a Firebase Bill of
Materials (BoM).

Add Firebase SDKs to your app using a Firebase BoM

Warning: Firebase BoMs are supported only as an
experimental feature for Firebase Android apps.

Using the Bill of Materials (BoM) Gradle feature with Firebase, you can set
the version of the Firebase platform as a whole. Each Firebase BoM version
contains compatible versions of the Firebase libraries; review the
release notes
for the library versions mapped to specific BoM versions.

Updating to the latest BoM version updates all of the Firebase Android
libraries to the latest versions available at the BoM's release.

To add Firebase SDKs to your app using a Firebase BoM:

For Gradle 5.0 and later, BoM support is automatically enabled.
Set up your dependencies in your module Gradle file (usually
app/build.gradle):

dependencies {
// Import the platform
implementation platform('com.google.firebase:firebase-bom:16.0.0')
// When using a BoM, dependencies don't require a specified version
// If you do specify a version, it overrides the library version specified in the BoM
implementation 'com.google.firebase:firebase-core'
implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.firebase:firebase-firestore'
}

After you add firebase-bom to your dependencies, you can declare
Firebase libraries without specifying their versions. When you want
to update Firebase library versions, you only need to update the Firebase BoM
version.

If you specify a version in your library dependency line
and you use a Firebase BoM, then the specified library version
overrides the version value contained in the BoM.