Adding Firebase Configuration (google-services.json) File to Your Android App
To send push notifications to your Android App, it is required to add Firebase Configuration (google-services.json) and Google Services Gradle Plugin to your App.
Step 1: Create a Firebase Project
If you already have a Firebase Project, jump to Step 2. Otherwise follow the steps at Creating a Firebase Project.
Step 2: Register your app with Firebase
- Go to the Firebase console of the project.
- In the center of the project overview page, click the Android icon.
-
Enter your app's package name in the Android package name field.
(Optional) Enter other app information: App nickname and Debug signing certificate SHA-1. - Click Register App.
Step 3: Add a Firebase configuration file
-
Add the Firebase Android configuration file (google-services.json) to your app:
- Click Download google-services.json to obtain your Firebase Android config file.
- Move the downloaded config file into the module (app-level) root directory of your app (usually <project>/app).
-
To make the values in your google-services.json config file accessible, you need the Google services Gradle plugin (google-services).
-
In your root-level (project-level) Gradle file (<project>/build.gradle), add the Google services 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 { ... // Add the dependency for the Google services Gradle plugin classpath 'com.google.gms:google-services:4.3.14' } }
Copy -
In your module (app-level) Gradle file (usually <project>/app/build.gradle), add the Google services plugin:
plugins { id 'com.android.application' // Add the Google services Gradle plugin id 'com.google.gms.google-services' apply true ... }
Copy - Click Sync Now .
-
In your root-level (project-level) Gradle file (<project>/build.gradle), add the Google services plugin as a buildscript dependency: