Skip to content

Instantly share code, notes, and snippets.

@AlexDisler
Last active August 24, 2021 09:53
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save AlexDisler/5f4486bec721bee53472e7a3044f6b20 to your computer and use it in GitHub Desktop.
Save AlexDisler/5f4486bec721bee53472e7a3044f6b20 to your computer and use it in GitHub Desktop.
.PHONY: run
# certs and output
OUTPUT_FILE=apkname.apk
ALIAS=youralias
KEYPASS=yourkeypass
KEYSTORE=certs/yourcert.keystore
UNSIGNED=platforms/android/build/outputs/apk/android-release-unsigned.apk
# or, if you're using Crosswalk:
# UNSIGNED=platforms/android/build/outputs/apk/android-armv7-release-unsigned.apk
PACKAGE='com.yourcompany.yourapp'
# create a signed apk
sign:
rm -f ${OUTPUT_FILE}
cordova build android --release
jarsigner -verbose -sigalg MD5withRSA -digestalg SHA1 -keystore ${KEYSTORE} -storepass ${KEYPASS} ${UNSIGNED} ${ALIAS}
zipalign -v 4 ${UNSIGNED} ${OUTPUT_FILE}
execute:
adb shell am start -n ${PACKAGE}/${PACKAGE}.MainActivity
# install a signed apk on a device
install:
adb install -r ${OUTPUT_FILE}
# monitor logs and filter by package name
log:
adb logcat | grep `adb shell ps | grep ${PACKAGE} | cut -c10-15`
run: sign install execute log
@verybluebot
Copy link

verybluebot commented Jul 13, 2019

thanks, very useful. Only one thing:
When you build a release the name of the file is app-release-unsigned.apk, NOT android-release-unsigned.apk

this took a few hours of my life..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment