Skip to content

Repository files navigation

ConfigDirector Android SDK

CI Latest version

Android SDK for ConfigDirector, remote config and feature flags with typed values, JSON Schema validation, and safe renames of live flags. Start free, no card required.

It is written in Kotlin and is meant to be used from Kotlin and Java alike, and it ships as three artifacts: com.configdirector:android-sdk, the SDK; com.configdirector:android-sdk-compose, optional Jetpack Compose bindings over it; and com.configdirector:android-sdk-testing, tools for testing the code that reads your configs.

This repository also holds com.configdirector:openfeature-android-provider, an OpenFeature provider built on the SDK, released on its own.

Install

The artifacts are published to the ConfigDirector Maven repository, https://maven.configdirector.com. Add the repository once, next to google() and mavenCentral() in settings.gradle.kts. Projects created by Android Studio declare their repositories there, under dependencyResolutionManagement, and by default refuse repositories declared in a module's build file. The repository, the signing key and how to verify what it serves are described at https://docs.configdirector.com/sdks/maven-repository.

dependencyResolutionManagement {
    repositories {
        google()
        mavenCentral()
        exclusiveContent {
            forRepository {
                maven {
                    name = "ConfigDirector"
                    url = uri("https://maven.configdirector.com")
                }
            }
            filter {
                includeGroup("com.configdirector")
            }
        }
    }
}

Or, in settings.gradle:

dependencyResolutionManagement {
    repositories {
        google()
        mavenCentral()
        exclusiveContent {
            forRepository {
                maven {
                    name = 'ConfigDirector'
                    url = 'https://maven.configdirector.com'
                }
            }
            filter {
                includeGroup 'com.configdirector'
            }
        }
    }
}

Then add the dependencies to your app module:

dependencies {
    implementation("com.configdirector:android-sdk:1.9.0")

    // Optional, for Jetpack Compose applications
    implementation("com.configdirector:android-sdk-compose:1.9.0")

    // For your tests
    testImplementation("com.configdirector:android-sdk-testing:1.9.0")
}

The SDK declares the INTERNET permission, which is merged into your application's manifest.

Retrieve a value

import com.configdirector.ConfigDirectorClient
import com.configdirector.value

val client = ConfigDirectorClient(applicationContext, "YOUR-CLIENT-SDK-KEY")
client.initialize()

val darkMode = client.value("dark-mode", false)

Full details are in the official documentation.

Test your code

com.configdirector:android-sdk-testing creates a test client: the SDK's real client connected to an in-memory server that your test controls. No network connection is opened, no telemetry is sent, and no Android Context is needed, so it runs in a plain JVM unit test.

import com.configdirector.testing.createTestClient

val testClient = createTestClient(values = mapOf("dark-mode" to true, "max-items" to 20))
testClient.client.initialize()

val settings = Settings(testClient.client)
assertThat(settings.isDarkMode).isTrue()

testClient.setValue("dark-mode", false)
assertThat(settings.isDarkMode).isFalse()

testClient.client is a ConfigDirectorClient, so it goes anywhere your code accepts one. From Java, ConfigDirectorTesting.createTestClient(values). See Test your code in the documentation for holding and failing initialization, the Compose bindings under test, and what to expect.

Documentation

Refer to the official documentation for the Android SDK.

There is also a quickstart guide for ConfigDirector and any of our SDKs.

Sample apps

samples/configdirector-android/ holds two Android apps built on this SDK, reading the same handful of configs and re-rendering as their values change. compose is Kotlin and Jetpack Compose; java is plain Java with framework views, no Kotlin sources at all.

samples/configdirector-openfeature-android-provider/ holds a Compose app reading the same configs through the OpenFeature provider.

They depend on the released artifacts, the way your own app would; -PuseLocalSdk builds them against this checkout instead. From the repository root, with a device or emulator running:

./gradlew :samples:configdirector-android:compose:installDebug

See samples/configdirector-android/README.md to point them at your own ConfigDirector project.

Getting Help

Releases

Used by

Contributors

Languages