Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Release APK builder that asks for your key passwords interactively, so you don't have to store them in your build script or VCS. For use with the Gradle build system. CC0 license.
// additional required configuration to hook into the build script
android {
signingConfigs {
buildTypes {
release {
signingConfig signingConfigs.release
// specify signing properties on the command line
if (hasProperty('storeFile')) {
println 'Generating a signed package.'
android.signingConfigs.release.storeFile = file(storeFile)
android.signingConfigs.release.storePassword = storePassword
android.signingConfigs.release.keyAlias = keyAlias
android.signingConfigs.release.keyPassword = keyPassword
} else {
android.buildTypes.release.signingConfig = null
if [[ $# -ne 1 ]]; then
echo "Usage: $0 keystore"
exit 1
if [[ ! -f $1 ]]; then
echo "$1 doesn't exist or isn't a keystore"
exit 1
read -s -p "Keystore Password: " STORE_PASS
read -p "Key Alias: " KEY_ALIAS
read -s -p "Key Password: " KEY_PASS
export ORG_GRADLE_PROJECT_storeFile="$1"
export ORG_GRADLE_PROJECT_storePassword="$STORE_PASS"
export ORG_GRADLE_PROJECT_keyPassword="$KEY_PASS"
./gradlew signingReport
read -p "Is this correct? [y/n] " -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]; then
./gradlew build

This comment has been minimized.

Copy link

minakolta commented Oct 8, 2013

where should i place ?


This comment has been minimized.

Copy link

joninvski commented Oct 18, 2013

Just a note:

In my case it only worked if i used project.hasproperty() instead of only hasproperty()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.