Secrets and Build Config

Understand how store secrets in local.properties and share the secrets in all the platforms (Android, iOS, Web, Desktop)

AppKickstarter leverages BuildKonfigarrow-up-right to store secrets and dispatch them in all platforms.

For example we have in local.properties this secret:

# Google Sign in
google_sign_in_web_client_id=

In Shared module (build.gradle file) we get the local.properties secrets and create usable constants:

buildkonfig {
    packageName = "com.appkickstarter.shared"

    val props = Properties()

    try {
        props.load(file("../local.properties").inputStream())
    } catch (e: Exception) {
        // keys are private and can not be committed to git
    }

    defaultConfigs {
        buildConfigField(
            STRING,
            "GOOGLE_SIGN_IN_WEB_CLIENT_ID",
            props["google_sign_in_web_client_id"]?.toString() ?: ""
        )
    }
}

This way we can use in Kotlin code (multiplatform) :

Last updated

Was this helpful?