I am using an API within my app. I currently manage the API key from a java interface
public interface APIContract {
//The API KEY MUST NOT BE PUBLISH. I
I put them on the global gradle.properties file on the dev machine or ci server. This way is not part of your project so you shouldn't worry about checking it in your repo, but it's still easily accessible from your gradle files.
Global gradle.properties file should be located inside ˜/.gradle on Mac for instance - btw, you should create it if it doesn't exist.
Then on your build.gradle file you can reference those properties and, for instance, expose them as buildConfigFields using the same name you used in your gradle.properties file
buildConfigField 'String', 'API_KEY', maps.api.key
Then on your Java/Kotlin code you can access them as BuildConfig.API_KEY