Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
bash script to sign cordova/phonegap android apks altogether
#!/bin/bash
APK_ARM_32="platforms/android/app/build/outputs/apk/armv7/release/app-armv7-release-unsigned.apk"
APK_X86_32="platforms/android/app/build/outputs/apk/x86/release/app-x86-release-unsigned.apk"
APK_ARM_64="platforms/android/app/build/outputs/apk/arm64/release/app-arm64-release-unsigned.apk"
APK_X86_64="platforms/android/app/build/outputs/apk/x86_64/release/app-x86_64-release-unsigned.apk"
// your keystore file and secret
KEYSTORE_PATH="/path/to/keystore"
KEYSTORE_PASS="*****"
# build 32bit apks
cordova build android --release
# build armv7 32bits
zip -d "$APK_ARM_32" META-INF/\*
zipalign -v -p 4 $APK_ARM_32 app_armv7_aligned.apk
apksigner sign --ks "${KEYSTORE_PATH}" --ks-pass "pass:${KEYSTORE_PASS}" --out app_armv7.apk app_armv7_aligned.apk
apksigner verify app_armv7.apk
rm app_armv7_aligned.apk
# build x86 32bits
zip -d "$APK_X86_32" META-INF/\*
zipalign -v -p 4 $APK_X86_32 app_x86_aligned.apk
apksigner sign --ks "${KEYSTORE_PATH}" --ks-pass "pass:${KEYSTORE_PASS}" --out app_x86.apk app_x86_aligned.apk
apksigner verify app_x86.apk
rm app_x86_aligned.apk
# build 64bit apks
cordova build android --release --xwalk64bit
# build armv7 64bits
zip -d "$APK_ARM_64" META-INF/\*
zipalign -v -p 4 $APK_ARM_64 app_armv7_64_aligned.apk
apksigner sign --ks "${KEYSTORE_PATH}" --ks-pass "pass:${KEYSTORE_PASS}" --out app_armv7_64.apk app_armv7_64_aligned.apk
apksigner verify app_armv7_64.apk
rm app_armv7_64_aligned.apk
# build x86 64bits
zip -d "$APK_X86_64" META-INF/\*
zipalign -v -p 4 $APK_X86_64 app_x86_64_aligned.apk
apksigner sign --ks "${KEYSTORE_PATH}" --ks-pass "pass:${KEYSTORE_PASS}" --out app_x86_64.apk app_x86_64_aligned.apk
apksigner verify app_x86_64.apk
rm app_x86_64_aligned.apk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment