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

WordPress Android App with REST API And Retrofit

Retrofit is the library which converts your JSON data into Java object. In this tutorial, we will learn about how to implement the Retrofit to create a WordPress Mobile App. As we all know, WordPress is the one of the biggest CMS (Content Management System) of the world. Wordpress full fill the requirements for all most every type of the website. So, in this tutorial, I am going to learn how to create an Android App using the WordPress REST API and Retrofit. What is Retrofit? If you want to know about Retrofit, I would like to give you just a simple one-line explanation of the Retrofit. It is a library which converts your REST HTTP request to Java interface. We will learn how we can do all these stuff using some very simple steps. Further, you can check the Retrofit Library here . So, In this tutorial, we will use the Retrofit to retrieve all post and there except ( A short Description of Post) form a WordPress website. Prerequisite for using the Retrofit for WordPress Android App Ther

Flutter State Management With Provider and ChangeNotifier

Flutter state management with provider library and why it's so important? There are lots of topics in flutter which are very important but out of those state management of your flutter application is the most important and little bit complicated as well. So in this article, I will try to explain how to use the provider package for managing the state of flutter and dart application and how to access the data down the hierarchy of the widget tree without recreating the whole UI. Basic knowledge of the state management and data flow in the Flutter Before starting the coding I would like to explain some basics about the Flutter application so that you can understand, why it's important to manage the state of your application in the correct way. In Flutter, everything is a widget and whenever the state of your application changes the UI is recreated the UI with the new data. Let's list out the topic or problem that we are going to explore about state management. Challenge o