I use the below command in order to generate a signed APK, I'm pretty sure this worked a few months ago:
$ ionic cordova build android --prod --release --keystore="./my-keystore-file.keystore" --storePassword=mypass --alias=mymail@gmail.com --password=mypass
However, only an unsigned APK is generated. How can I generate a signed APK using ionic?
publishing ionic android app..
ionic cordova platform add android
cordova build android --release
platforms/android/build/outputs/apk
. Now, we need to sign the unsigned APK.Let’s generate our private key using the
keytool
command that comes with the JDK.enter password for the
keystore
file. remeber this password, it will be useful in future.after entering all fields, it will generate a keystore file. save copy of it somewhere else for future use.if you lose it you won’t be able to submit updates to your app!jarsigner
tool which is also included in the JDK:for easy use, copy unsigned to apk to project's root and just use filename.apk in place of path.
it will ask us to enter the keystore password.
zip align
tool to optimize the APKNow we have our final release binary called HelloWorld.apk and we can release this on the Google Play Store.
source: ionic docs
You need to include
-- --
before the Cordova-specific arguments:The
build android --prod --release
options are handled by the Ionic CLI, whereas everything after the first--
is passed to the Ionic Cordova plugin. Then everything after the 2nd--
is passed to Cordova itself.