Android Sign+Zip Bash Script (For Mac/Linux Users)


So I don’t have Android Studio and I was getting tired of going on the Ionic website to look at the commands to sign, and zip my android builds every time I made a release so I created a bash script.

In your in your home directory, open your .bash_profile (if you’re using atom, in your terminal type atom .bash_profile) and just paste the following in with your directory to your apk:

alias andbuild='cd ~/path/to/platforms/android/build/outputs/apk; rm android.apk; jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore android-release-unsigned.apk alias_name; zipalign -v 4 android-release-unsigned.apk android.apk'

This works for me, but if you want to use custom names, or have to use custom names, use this script.

alias andbuild='_(){ cd ~/path/to/platforms/android/build/outputs/apk; jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore $1-release-unsigned.apk alias_name; zipalign -v 4 android-release-unsigned.apk $2.apk; };_'

So in the terminal, as it takes two parameters ($1, $2) you would type: andbuild android myapp.

If you only want need 1 parameter to call, just change $2.apk to $1.apk

Hope’s this helps streamline things for someone.