As an Android Engineer, I have to sign Android apps whenever making a public release. The steps are quite simple and well documented on the official website. However the one thing that always comes up how do you provide your signing credentials and keystore file. Lets find out!
There 2 common ways this can be done:
Using ENV vars (Recommended)
Inside your ~/.zshrc or ~/.bashrc file, declare the key value pairs as shown below:
Note: For CI, declare key-value pair under secrets section
defkeystorePropertiesFile=rootProject.file("local.properties")if(keystorePropertiesFile.exists()){// Load the properties
defkeystoreProperties=newProperties()keystoreProperties.load(newFileInputStream(keystorePropertiesFile))android{signingConfigs{if(keystorePropertiesFile.exists()){release{keyAliaskeystoreProperties['keyAlias']keyPasswordkeystoreProperties['keyPassword']storeFilefile(keystoreProperties['storeFile'])storePasswordkeystoreProperties['storePassword']}}}buildTypes{release{if(keystorePropertiesFile.exists()){signingConfigsigningConfigs.release}}}}}else{println("Filename: keystore.properties")println("Error: File does not exists")println("Solution: Create a keystore.properties file with valid details under keystore directory at the root of your project")}
Now in order to use this signing.gradle config in your app, open the build.gradle file for app module and add the the below line of code just above the android {} block: