Hiding API keys in local.properties Add the API key to your local.properties file: apiKey=<value> Add to the build.gradle.kts file (module-level): import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties Add to the android { defaultConfig { } } block of your module-level build.gradle.kts file: android { // ... defaultConfig { // ... buildConfigField("String", "API_KEY", gradleLocalProperties(rootDir).getProperty("apiKey")) } // ... } Sync Gradle and build the project. You can now reference the key: val apiKey = BuildConfig.API_KEY