hide api key in android code example
Example: java android build secret keys
// Root-level file secrets.properties
SECRET_KEY="ABC123"
// In module level build.gradle
def secretsPropertiesFile = rootProject.file("secrets.properties")
def secretsProperties = new Properties()
secretsProperties.load(new FileInputStream(secretsPropertiesFile))
defaultConfig {
buildConfigField("String", "SECRET_KEY", secretsProperties['SECRET_KEY'])
}
// Now accessible in the code
String consumerKey = BuildConfig.SECRET_KEY;