I am new to android and working on a project where I see that the API key that I got is saved in gradle.properties
as :
MyOpenWeatherMapApiKey=\"1
gradle.properties
is a local file and should not be stored under the version control, and BuildConfig
is a generated class, so it will only be created at build time. It's definitely easier to store the API key somewhere as a plain String, but then you'll have to commit it to the repo.BuildConfig
file to store some build-related constants. You can use buildConfigField
command to instruct Gradle to add custom fields into BuildConfig
. After the project is built, you can reference these constants inside your source code.