Skip to content

Instantly share code, notes, and snippets.

@favasconcelos
Last active July 24, 2018 13:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save favasconcelos/ade0c2c26b6344ec383c26cea05fd2a3 to your computer and use it in GitHub Desktop.
Save favasconcelos/ade0c2c26b6344ec383c26cea05fd2a3 to your computer and use it in GitHub Desktop.
Signing Android APK without changing the build.gradle (Same key is used for release and debug). The keystore.json is in the root directory of the project.
android {
signingConfigs {
key {
// Load keystore credentials from a config file
def credsFilePath = file("../keystore.json").toString()
def credsFile = new File(credsFilePath, "").getText('UTF-8')
def json = new groovy.json.JsonSlurper().parseText(credsFile)
// Save the config into the variables
storeFile file(json.android.storeFile)
storePassword json.android.storePassword
keyAlias json.android.keyAlias
keyPassword json.android.keyPassword
}
}
buildTypes {
release {
// ...
signingConfig signingConfigs.key
}
debug {
// ...
signingConfig signingConfigs.key
}
}
// ...
}
{
"android": {
"storeFile": "paht/to/file/keystore.jks",
"storePassword": "storePassword",
"keyAlias": "keyAlias",
"keyPassword": "keyPassword"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment