Skip to content

Instantly share code, notes, and snippets.

@jaysondc
Last active July 26, 2017 21:23
Show Gist options
  • Save jaysondc/81b2e39766b8e40f183e5d63151f09c1 to your computer and use it in GitHub Desktop.
Save jaysondc/81b2e39766b8e40f183e5d63151f09c1 to your computer and use it in GitHub Desktop.
Sign APK without putting keystore info in build.gradle

Sign an APK without putting keystore info in your build.gradle file

  1. Add the following code to your build.gradle file.
// Load keystore
def keystorePropertiesFile = rootProject.file("keystore.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

android {
    ...
    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile file(keystoreProperties['storeFile'])
            storePassword keystoreProperties['storePassword']
        }
    }
    ...
}
  1. Create a file called keystore.properties in the root directory of your project:
keyAlias=my_key_alias
keyPassword=key_password
storeFile=C:/Users/escape\ spaces\ like\ this/Path/To/My/Keystore.jks
storePassword=keystore_password
  1. Add the following line to your .gitignore file.
keystore.properties
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment