Create Custom Build Config Variables

Add Custom fields to

android {
    buildTypes {
        def localProperties = new Properties()
        localProperties.load(new FileInputStream(rootProject.file("local.properties")))
        
        debug {
            buildConfigField("String", "API_KEY", "\"" + localProperties['apiKey'] + "\"")
        }
        release {
            buildConfigField("String", "API_KEY", "\"" + localProperties['apiKey'] + "\"")
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

Last updated