Skip to content

Instantly share code, notes, and snippets.

@ddm
Created February 8, 2017 08:22
Show Gist options
  • Save ddm/959d24b897d71946165b29995e053a54 to your computer and use it in GitHub Desktop.
Save ddm/959d24b897d71946165b29995e053a54 to your computer and use it in GitHub Desktop.
Unpack or pack an apk
#!/usr/bin/env bash
DIR=`dirname $0`
TARGET_APK="target.apk"
TARGET_DIR="target"
if [[ ! "$1" =~ ^(unpack|pack)$ ]]; then
echo "Choose 'unpack' or 'pack'"
exit 1
fi
if [[ $1 == "unpack" ]]; then
rm -rf $DIR/$TARGET_DIR
apktool d $DIR/$TARGET_APK
elif [[ $ENV == "pack" ]]; then
apktool b $DIR/$TARGET_DIR
keytool -genkey -v -keystore $DIR/$TARGET_DIR/temporary.keystore -alias temporary -keyalg RSA -keysize 2048 -validity 20000
jarsigner -keystore $DIR/temporary.keystore -verbose $DIR/result.apk temporary
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment