Created
April 25, 2016 08:03
-
-
Save TommyLau/42deb6338fde0e48f5eab78d2d7bd16e to your computer and use it in GitHub Desktop.
Android 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 | |
# Sample usage is as follows; | |
# ./signapk myapp.apk debug.keystore android androiddebugkey | |
# | |
# param1, APK file: Calculator_debug.apk | |
# param2, keystore location: ~/.android/debug.keystore | |
# param3, key storepass: android | |
# param4, key alias: androiddebugkey | |
USER_HOME=$(eval echo ~${SUDO_USER}) | |
# use my debug key default | |
APK=$1 | |
KEYSTORE="${2:-$USER_HOME/.android/debug.keystore}" | |
STOREPASS="${3:-android}" | |
ALIAS="${4:-androiddebugkey}" | |
# get the filename | |
APK_BASENAME=$(basename $APK) | |
SIGNED_APK="signed_"$APK_BASENAME | |
#debug | |
echo param1 $APK | |
echo param2 $KEYSTORE | |
echo param3 $STOREPASS | |
echo param4 $ALIAS | |
# delete META-INF folder | |
zip -d $APK META-INF/\* | |
# sign APK | |
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore $KEYSTORE -storepass $STOREPASS $APK $ALIAS | |
#verify | |
jarsigner -verify $APK | |
#zipalign | |
zipalign -v 4 $APK $SIGNED_APK |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment