Hiding API keys in local.properties Add the API key to your local.properties file: apiKey=<value> Add to the root level of your app-level build.gradle file: def localProperties = new Properties() localProperties.load(new FileInputStream(rootProject.file("local.properties"))) Add to the android { defaultConfig { } } block of your app-level build.gradle file: android { // ... defaultConfig { // ... buildConfigField "String", "API_KEY", localProperties['apiKey'] } // ... } Sync Gradle and build the project. You can now reference the key: val apiKey = BuildConfig.API_KEY