java android build secret keys

Java
// 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;
Source

Also in Java: