In a previous blog post, I went over the setup and use of Firebase Analytics and Crash Reporting. Another offering from the new Firebase suite is Remote Config, which brings a lot of potential functionality to an app, such as: A/B Testing, app customization based on what Firebase Audience a user is in, or just dynamic configuration settings for an app. This blog post will show a few examples of how to take advantage of Remote Config, and how it can be incorporated with Firebase Analytics.


This post assumes that you have already created a Firebase project. If you are unsure of how to do this, please check my previous blog or the official Firebase documentation for Android.

The first step is to add Remote Config to the application.

// in the build.gradle for your app
compile ''

Then get an instance of the Remote Config.

FirebaseRemoteConfig firebaseRemoteConfig = FirebaseRemoteConfig.getInstance();

Once you have a Remote Config instance you can use it to retrieve default config values, as well as fetch up-to-date values from the server. Note -- the XML file for the default config parameters should be stored in your res/xml directory, and the default parameters can be loaded with:


Fetching the Configuration

Pulling in new configuration parameters is a simple call to the Remote Config API, and once a successful response has been received, the new configuration parameters can be activated. Once the new parameters are activated they can be accessed through the FirebaseRemoteConfig.getXYZ(… ) methods.

firebaseRemoteConfig.fetch(3600 /* cache expiration time */)
 .addOnCompleteListener(this /* activity reference */, new OnCompleteListener() {
 @Override public void onComplete(@NonNull Task task) {
 if (task.isSuccessful()) {
 // successful fetch, activate the new values
 } else {
 // call has failed

Creating a Configuration Parameter

To create a Remote Configuration parameter, just open the Firebase Console and select your project, then navigate to Remote Config and select "Add Parameter", giving the parameter a name and value. You can also define conditions for parameters by selecting "Add value for condition" when creating or editing a parameter. Conditions come with several included options including random percentile of users, OS type, and also for Firebase Analytics Audiences. Once all of the parameters are created and the conditions are set, select "PUBLISH CHANGES" to finalize the new configuration. Once you publish the changes, they are immediately available to your apps.

Adding/Updating parameters

Adding/Updating parameters

It is important to note that for a given parameter, the conditions are evaluated in the defined order until the first true condition is met, or the default value is reached. Also, if you define a condition for a parameter based on a Firebase Analytics Audience, that condition will not be met with true until the user has become a part of the Audience. On first launch your app, a new user will not be registered for any Audiences until the first initial upload to Analytics, so it is important to have potential important Audiences created early.

Defined Conditions

Defined Conditions

Sample application

To demonstrate some possibilities of the Firebase Remote Config I've built a small sample application that will pull in some information about a github user, as well as have an option to display a list of the user's github repositories. The application will use Remote Config values to define the app's theme, as well as feature locking for the repository list activity (the activity is purposefully designed to crash on Android 5.1 devices). The sample code can be found on github. Note: the sample app uses a small splash screen to pull in Remote Configuration values so that we can style our activities on first launch. Adding a splash screen just to pull in configuration values may not be suitable for all apps, so it is important to investigate appropriate places for fetching the Remote Config for each application.

Using User Percentile based conditions on configuration values is a good way to test new themes or styles in your apps without fully rolling them out. For the sample app, there are two extra User Percentile conditions applied to the "theme" configuration value, giving us three potential themes for users to see. This is a simple, powerful way to do A/B Testing within an application.

Separate Themes

Three different app themes set by a Remote Config parameter

Remote Config parameters can also be used to achieve feature switching (enabling/disabling). With a Firebase Analytics Audience for all Android 5.1 users, it is possible to hide or display the "VIEW REPOS" button after searching for a github user. This is accomplished by having a "view_repos_enabled" parameter and setting a condition on that parameter where all users belonging to the Android 5.1 Audience will receive a value of "false", signaling to hide the button. All other users would receive a value of "true", and display the button. This allows restriction of potential problem OS's or devices from certain features of the application, providing a better user experience.

Separate Themes

5.1 device with missing repo button

Using Remote Config for something like feature switching gives greater control over the app after a new release. If there is a major issue with a certain device or OS on a new application, a feature switch based off a configuration parameter is a great way to disable the feature while working on a solution. This offers a much improved user experience, but it is important to have meaningful Firebase Analytics Audiences defined early, as creating an Audience will not retroactively populate the Audience with users.


Firebase Remote Config is a powerful and easy to add module of Firebase that hooks into Firebase Analytics to allow a very customizable experience. Whether it's being used for simple configuration values, such as different labels or flavor text, or if it's being used to conduct A/B testing or feature switching, Remote Config is a flexible tool that can immediately bring value to many applications. Because of this, Remote Config is one of the many pieces of the Firebase suite of products that should be considered for existing and new applications.

About the Author

Alex TownsendAlex is a Senior Consultant at CapTech, based in Washington, DC. Alex has a passion for Android application development and architecture, focusing on bringing the latest and greatest technologies and patterns to his work.