AndroidPub
Published in

AndroidPub

How to use a Different google-services.json file with multiple Product flavors — Android

Different google-services.json file with Multiple Product flavors.

Image for Different google-services.json file with different flavors

The google-services.json file is usually placed in the app/ root directory of the app module.

Now, in this article, we will learn how to use a google-services.json file with multiple product flavors, when we have different google-services.json file according to the need of our project.

How you get the file:

The firebase will help you to download the google-services.json file when you need to integrate FCM, crashlytics etc..

Usage:

How to use this file for different product flavors. There are only 3 steps first step is so simple just remove the google-service.json file from the root of the app/ module and save it your local system directory for the save side, & then make your product flavors like Production & Staging environment.

Step1:

Make a production folder in the src folder and put your production google-services.json file in the root folder of production, like the below screenshot.

ScreenShot for Android Studio Production folder

Step2:

Make a staging folder in the src folder and put your staging google-services.json file in the root folder of staging, like the below screenshot.

ScreenShot for Android Studio Staging folder

That’s it now sync your project with Gradle files.

Highlighted one is the sync icon

If you want to learn more related to Android then check it out the below link:

Sharing Knowledge is Caring 😊

Thanks for reading this article. Be sure to clap to recommend this article if you found it helpful. It means a lot to me.

If you need any help then Join me on Twitter, Linkedin, Github, and Subscribe to my Youtube Channel.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Danish Amjad

Danish Amjad

Senior Mobile Engineer (Android). Open Source Contributor, Technical Writer, Email: Dani.amjad12@gmail.com check my website at https://danishamjad.com/