local.properties
file:apiKey=<value>
build.gradle
file:def localProperties = new Properties()
localProperties.load(new FileInputStream(rootProject.file("local.properties")))
android { defaultConfig { } }
block of your app-level build.gradle
file:android {
// ...
defaultConfig {
// ...
buildConfigField "String", "API_KEY", localProperties['apiKey']
}
// ...
}
val apiKey = BuildConfig.API_KEY