Creating a Custom Feature Flagging Platform for Android with Firebase

Martin Macheiner
3 min readAug 29, 2018


Sometimes a new rollout for a feature can be quite challenging, and maybe the feature shows some defects, which you want to disable for now until it is fixed in the next release cycle. Talking about this in the mobile context, a new release through the app stores is necessary, which happens not instantaneous. However, companies like Google and Facebook heavily depend on so-called “feature flags”. This is basically an if/else construct in your code, which allows the companies to roll out new features to their audience at any point in time. But feature flagging also brings benefits to all app developers: A/B testing or as mentioned partial feature roll-outs. In the next 5–10 minutes I will show you how you can build your own small feature flagging platform on top of Firebase. There are some dedicated feature flagging tools out there like LaunchDarkly, which offer tons of additional features. I want to focus on the key point and how you can get the best out of Firebase.

If you want to read more about feature flagging, I suggest you start with the article of Justin Baker (Lead product designer at LaunchDarkly) here.

The setup

The setup is pretty easy. We have an Android app with 2 features we want to control remotely: showInAppPurchase should only enable the UI for a dialog for an in-app purchase, while enableCoolBackendFeature will bring more advanced functionality to the app. We are not going into detail about this. The interface is straightforward with 2 boolean properties.

For an early development stage, we can fall back to a default implementation, which returns hardcoded values.

Later we replace the DefaultFeatureFlagging implementation with the more advance FirebaseFeatureFlagging implementation.

The Firebase logic is also relatively simple. We rely on Firebase Remote Config, which allows us to publish key-value pairs over a web console to users. The implementation fetches new data on object instantiation. The FirebaseRemoteConfig implementation caches the values 12 hours by default. The corresponding properties are linked with the remote config flags. If you want to use it in the code you just have to call:

if (featureFlagging.showInAppPurchase) {
// TODO show in-app purchase dialog

That´s all.

Setup Firebase Remote Config

I’m not going into detail how to fully set up Firebase Remote Config, as there is already an awesome tutorial in their docs here. I just want to outline that setting up the remote config object only requires about 6 lines of code. The only important thing here is, that Remote Config requires a set of default values, so your flags have always a defined state.

I personally use Dagger to inject this object into the FirebaseFeatureFlagging class.

Leveraging the capabilities of Firebase Remote Config

It´s only fair to say, that this implementation of a feature flagging platform using Firebase lacks a lot of functionality and is not meant to a replace dedicated feature flagging platforms. However, it still has some cool features. First, it has a very simple UI. Second, and more important: It allows you to define conditions. The flag cool_feature, for example, will only address phones, which are currently located in Germany. So in this example, the developer can decide to try a specific feature on the German market, before releasing it worldwide. Other conditions include device language, app version, OS type (Android/iOS) or users in randomly assigned percentile.

Firebase Remote Config


The very simplistic example shows how each developer can build its individual feature flagging platform with very low effort. Of course, this lacks some essential features, which are available on bigger platforms. This implementation does not support A/B testing (although implicitly it supports it, as firebase provides a separate feature for A/B testing based on Remote Config), a real precise roll-out strategy and a limited set of conditions.

This tutorial is more about how you can easily leverage the benefits of a feature flagging platform for small to mid-sized projects.