I am trying to learn the basics of git and github along with Android programming so that I can show my work to employers in future.
I have done some projects which requires API keys.I've understood that I have to remove my API key before sharing code publicly in github. I've also learnt that .gitignore can be used in the git command line to ignore files that we do not want to be upload.
I read a lot of stack overflow posts and other Q&A sites to exactly see where I have to store my API KEY so that I can ignore that file using .gitignore. There were many suggestions and I am following one of the suggestions from here to store my API key in gradle.properties like
MY_PRIVATE_API_KEY=12345 and then in build.gradle like
buildTypes { debug{ buildConfigField("String", "FORECAST_VERIFICATION_API_KEY", "\"" + MY_PRIVATE_API_KEY +"\"") minifyEnabled false applicationIdSuffix ".debug" } } and finally in the code to reference it like
String api_key = BuildConfig.FORECAST_VERIFICATION_API_KEY; Now I want to make sure if this aproach is correct before uploading my project publicly.
My .gitignore file is like this
I see the .gitignore has .gradle in it. Does this mean the gradle.properties where I have stored my API key will be ignored?I am totally confused.Am I following the right approach?
