Last active
February 10, 2019 05:20
-
-
Save codeniko/cdc8ff7dd4efc8fbceae55c0e6b165b0 to your computer and use it in GitHub Desktop.
sign apk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Key Vars | |
keyfile='my-release-key.jks' | |
# APK Vars | |
filename="${1%.*}" | |
ext='.apk' | |
aligned="$filename-aligned$ext" | |
signed="$filename-signed$ext" | |
function generate_key { | |
echo 'Need to generate release key, fill out the information below' | |
keytool -genkey -v -keystore "$keyfile" -keyalg RSA -keysize 2048 -validity 10000 -alias my-alias | |
} | |
function sign_apk { | |
echo "Signing $1" | |
zipalign -v -p 4 "$1" "$aligned" | |
apksigner sign --ks "$keyfile" --out "$signed" "$aligned" | |
} | |
if [ -f "$keyfile" ]; then | |
sign_apk "$1" | |
else | |
generate_key | |
if [ "$?" -eq 0 ]; then | |
sign_apk "$1" | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment