Android & Kotlin experience cheat sheet
Android
Store secrets
Go to gradle.properties
and save it there as key/value pairs. Exclude this file from GIT. This make it harder for others to read your secrets from your repository or using the APK file.
We could use Android’s ProGuard to make this more secure. This doesn’t provide 100% security. The best way is to keep your keys outside the project. Store them in a backend server and retrieve them after authentication. Checkout this article and this one for more information on storing secrets in Android.
MY_KEY = "1029831283712090989087"
Open the app level build.gradle
file.
android {
defaultConfig {
buildConfigField("String", "API_KEY", MY_KEY)
}
buildTypes {
release {
// this deletes unused classes and files from the APK
minifyEnabled true
shrinkResources true
}
}
}