The simplest and cleanest way to add an external configuration is through a separate Gradle file
build.gradle
apply from: './keystore.gradle'
android{
signingConfigs {
release {
storeFile file(keystore.storeFile)
storePassword keystore.storePassword
keyAlias keystore.keyAlias
keyPassword keystore.keyPassword
}
}
}
keystore.gradle
ext.keystore = [
storeFile : "/path/to/your/file",
storePassword: 'password of the store',
keyAlias : 'alias_of_the_key',
keyPassword : 'password_of_the_key'
]
The keystore.gradle file can exist anywhere in your file system, you can specify its location inside the apply from: ''
at the top of your gradle file or at the end of your main project build.gradle file.
Typically its a good idea to ignore this file from version control system such as git if its located inside your repo.
It is also a good idea to provide a sample keystore.gradle.sample
which developers entering the project would rename and populate on their development machine. This file would always be contained inside the repo at the correct location.