Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Creates a signed and zipaligned APK from your Ionic project
# Creates a signed and zipaligned APK from your Ionic project
# Place your keystore in the root of your project and name it <company>.keystore
# Use this script as following :
# $ ./ [company] [version]
# Don't forget to gitignore your key and your compiled apks.
# Original at
# Author : Erwan d'Orgeville<>
# Abort if any command returns something else than 0
set -e
appname=${appname_dirty//[^a-zA-Z]} # Keeps only a-z letters
if [[ -z "$1" ]]; then
echo "No company name provided, aborting..."
exit 1
if [[ -z "$2" ]]; then
echo "No version provided, aborting..."
exit 1
echo "---> Starting build v$version"
ionic build --release android
echo ""
echo ""
echo "---> Input the password for the key"
jarsigner -sigalg SHA1withRSA -digestalg SHA1 -keystore $company.keystore platforms/android/build/outputs/apk/android-release-unsigned.apk $company
cp platforms/android/build/outputs/apk/android-release-unsigned.apk platforms/android/build/outputs/apk/com.$company.$appname.v$version-unaligned.apk
echo ""
echo ""
echo "---> Zipaligning"
mkdir -p releases/
zipalign -v 4 platforms/android/build/outputs/apk/com.$company.$appname.v$version-unaligned.apk releases/com.$company.$appname.v$version.apk
echo ""
echo ""
echo "---> App released ! Look for com.$company.$appname.v$version.apk"
open releases/
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.