You can define the signing configuration to sign the apk in the build.gradle file using these properties:
storeFile : the keystore filestorePassword: the keystore passwordkeyAlias: a key alias namekeyPassword: A key alias passwordIn many case you may need to avoid this kind of info in the build.gradle file.
It’s possible to configure your app’s build.gradle so that it will read your signing configuration information from a properties file like keystore.properties.
Setting up signing like this is beneficial because:
build.gradle filekeystore.properties file from version controlFirst, create a file called keystore.properties in the root of your project with content like this (replacing the values with your own):
storeFile=keystore.jks
storePassword=storePassword
keyAlias=keyAlias
keyPassword=keyPassword
Now, in your app’s build.gradle file, set up the signingConfigs block as follows:
android {
...
signingConfigs { release { def propsFile = rootProject.file(‘keystore.properties’) if (propsFile.exists()) { def props = new Properties() props.load(new FileInputStream(propsFile)) storeFile = file(props[‘storeFile’]) storePassword = props[‘storePassword’] keyAlias = props[‘keyAlias’] keyPassword = props[‘keyPassword’] } } }
}
That’s really all there is to it, but don’t forget to exclude both your keystore file and your keystore.properties file from version control.
A couple of things to note: