Skip to main content

Firebase Remote Config Step by step Guide

 Firebase Remote Config enables you to dynamically change the layout and behavior of your app without changing the coding of your App. Event its no requirement you to create any backend servers. Just you have to follow some easy steps your app change the layout behavior during the run time depending on the condition that you set from Google Firebase. Hence it is an extremely good solution provided by google to easily change the layout of your App at the run time.

Firebase Remote Config Prerequisites

For configuration of Firebase Remote Config, we required some prerequisites which need to be done. First of all for configuring the remote config you need to setup a Firebase account. Go to Firebase home page and register your self if not register yet or login to Firebase.

Then click on Get Started For Free for testing purpose and then click on Create New Project.

It will open a popup window and ask for project name and country, enter the project name and select the country and click on Create Project as given below.

Here you can see the dashboard  of your Firebase home page. Here you have add your application into this project, So click on Add Firebase to your Android App option.

It open a popup and asks for your app package name and SHA1 key but SHA key is the optional for remote config so you can left in blank,  click on ADD APP button for next action.

Here it prompt you to save google-services.json, store this file to your computer will use this later in our application. You can download it anytime after login into the firebase.

Click on the continue button to move to the next step, it will give you some configuration step for your app which need to be done for your app we will this when start creating our application.

Create Project for Firebase Remote Config

We are going to create our project now using Android Studio for our Firebase Remote Config Demo.

Steps to Create Project

  • From Menu Bar Click on File

  • Select New > New Project

  • Put the Name of the project ( Name should be same as we have in Firebase Remote Config Project Dashboard)

  • Package name should be also same as we have configured during Firebase Remote Config app addition

Follow the rest of the steps to complete the full steps. At the last steps, you should select the empty Activity and click on finish button for this Demo. The project will be get created and will be open, do nothing here we have do the configuration first for firebase integration as provided in last steps of our app addition steps in firebase.

Set Remote Config JSON Configuration to your App

Did you remember we have saved the google-services.json configuration file during our app addition steps into firebase. Copy that file and paste it inside your application home app folder, in my case location as given below.
 E:MyProjectDebugAndroid ExampleRemoteConfigapp  

Dependency Configuration for Firebase Remote Config

There is some dependency which needs to be injected inside our project level build.gradle file. So configuring the dependency open the project build.gradle file and modify it as given below.
  dependencies {  
classpath ''
classpath ''

We also required configuration of the firebase library to our app level build.gradle file. So open your app level build.gradle file and put the below line under the dependencies section.
 compile ''  
compile ''

The last step is to add the google service plugin to your project. So for the addition of this, we need to add below configuration at the end of your app level build.gradle files. and click on sync now.
 apply plugin: ''  

So finally click on the sync button from top right corner to sync your project with the configuration change which we did in our build.gradle file.  As of now we have completed our project level configuration. Hence in next section, we are moving into integration part of our app with firebase.

Remote parameter Configuration and Implementation

Till now we have learned that how to configure your app to work with Firbase and Remote configuration. In this part we will configure our remote parameter and test our app.
Login to Firebase and select your project and click on RemoteConfig at the bottom of your left menu bar.


Enter your Parameter Key same as you are going to use in your app and default value that you want and click on ADD PARAMETER.
If you want you can add more parameter and modify an existing one from here, as of now we are taking only one parameter for our application.

Implementation of Remote Parameter to code

We are adding a textview to our main Activity xml files here so that we can show our remote value in this textbox in real case you can do whatever you want do with these remote parameter.

 <?xml version="1.0" encoding="utf-8"?>  
<RelativeLayout xmlns:android=""
android:text="Remote Config Parameter Not set" />

Implementing the Firebase Remote Config

Open the and modify it as given below.
 package com.debugandroid.remoteconfig;  
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
import java.util.HashMap;
import java.util.Map;
public class MainActivity extends AppCompatActivity {
private FirebaseRemoteConfig mRemoteConfig;
private TextView txt_remote_config;
protected void onCreate(Bundle savedInstanceState) {
//Initializing the RemoteConfig instance
mRemoteConfig = FirebaseRemoteConfig.getInstance();
FirebaseRemoteConfigSettings firebaseRemoteConfigSettings =
new FirebaseRemoteConfigSettings.Builder()
// Define default configuration values. It can be used in case where
// config not fetched due to any issue
Map<String, Object> defaultConfigMap = new HashMap<>();
defaultConfigMap.put("remote_test_parameter", 20);
// Apply the configuration settings and default values of remote config.
txt_remote_config= (TextView) findViewById(;
//calling the loadConfig Method to fetch the remote configuration
private void loadConfig() {
long cacheExpiration = 3600; // we set here 1 hours in seconds
// If developer mode is enabled we need to reduce cacheExpiration to 0 so that
// every time our app fetch the config from remote server.
// remove the below line of if condition code in release version
if (mRemoteConfig.getInfo().getConfigSettings()
.isDeveloperModeEnabled()) {
cacheExpiration = 0;
.addOnSuccessListener(new OnSuccessListener<Void>() {
public void onSuccess(Void aVoid) {
//calling the ApplyConfig method to apply the fetch configuration
.addOnFailureListener(new OnFailureListener() {
public void onFailure(@NonNull Exception e) {
Log.w("RemoteConfig", "Error fetching config: " +
// On error we can apply different method or we can use the same as well
// As we have already set the default value
private void applyOnFailure() {
String remote_value=mRemoteConfig.getString("remote_test_parameter");
txt_remote_config.setText("Remote Config fetch failed, Setting Default value is:" + remote_value);
private void applyConfig() {
String remote_value=mRemoteConfig.getString("remote_test_parameter");
txt_remote_config.setText("Remote Config fetch, value is:" + remote_value);


Setting permission to your Project

We required internet access to work the Firebase Remote Config, So add the required permission inside your project AndroidManifest.xml file.

<uses-permission android:name="android.permission.INTERNET" />We have done with completed the integration of the Firebase Remote Config Parameter, you can test your app now. Here is the sample output of our remote config demo app which we have created in this tutorial. One snap for Success Case  and with Failure case, you can create the scenario by enabling and disabling the internet service.

Firebase Remote Config
Success Case

Failure Case

Source Code of this demo app are available on GitHub you can download form here.


  1. […] any android app to google to get the configuration file then you can follow the process defined in Firebase Remote Config Prerequisites section or our earlier post. You have to just change the API name at final stage as given […]


Post a Comment

Popular posts from this blog

Flutter How to Start Android Activity from Flutter View

Flutter and Dart is an excellent combination for creating the UI, but for accessing the platform-specific service we need to open platform-specific activity. So lets in this article we will explore how to start an android activity and access the service from Flutter View. Create a Project for this Android Activity Flutter View Demo Create a Project From File menu select the New Flutter Project Enter the project name Select the AndroidX support and click on next After the above, we step click on Finish We will have the following project structure created. Create the Second Activity in Android Just go to the android folder and open it in separate windows. We will have the following project structure. Create the Activity Just right-click on the Kotlin folder and create a blank activity from the menu. If you create the activity then you may be required to upgrade the Gradle and do some import. So Just click on update and wait for the project s

Kotlin Parcelable Array Objects Send To Activity

We know that IPC (Inter Process Communication) between the activity is an extremely important part of any application development. We often required that we need to send some data to other activity. For example, we may be required to send an array of data, data could be an Integer, String, Long, Double, Float or any other custom data objects. So, In this example, we are going to learn how to implement the Kotlin Parcelable Array object to send the data from one activity to second activity. What is Parcel? The parcel class is designed as a high-performance IPC transport. A Parcel can contain both flattened data that will be unflattened on the other side of the IPC, and references to live IBinde r objects that will result in the other side receiving a proxy IBinder connected with the original IBinder in the Parcel. Create Kotlin Parcelable Array Objects Parcelable is API for placing the arbitrary objects into the Parcel. In Actual in android app development, Parcelable is an interface

Scan and List All Available WiFi Network In Android

In this tutorial, we learn how to connect to a WiFi hotspot in android by code. In this Demo we will create an as small app which will scan the all available network or Hotspot and list down the network when you select specific network, the application will connect that particular network. You May Like Below Topic: How to Read and Write JSON data using GSON WP Android App using REST and volley WP Android App using REST and volley part2 Implementation of SwipeRefreshLayout in RecyclerView Create Amazing Bottom Navigation Bar Without Any External Library Introduction In this tutorial, we learn how to connect to a WiFi hotspot in android by code. In this Demo we will create an as small app which will scan the all available network or Hotspot and list down the network when you select specific network, the application will connect that particular network. We will add this functionality to our existing Demo app " Video Gallery ". If you would like to check out t