Reputation: 15133
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 [email protected] --password=mypass
However, only an unsigned APK is generated. How can I generate a signed APK using ionic?
Upvotes: 5
Views: 3490
Reputation: 9708
You need to include -- --
before the Cordova-specific arguments:
$ ionic cordova build android --prod --release -- -- --keystore="./my-keystore-file.keystore" --storePassword=mypass [email protected] --password=mypass
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.
Upvotes: 8
Reputation: 2940
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.
keytool -genkey -v -keystore <name_of_keystore>.keystore -alias alias_name
-keyalg RSA -keysize 2048 -validity 10000
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:jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore name_of_keystore.keystore path_to_unsigned_apk_file.apk alias_name
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 APKzipalign -v 4 HelloWorld-release-unsigned.apk new_apk_name.apk
Now we have our final release binary called HelloWorld.apk and we can release this on the Google Play Store.
source: ionic docs
Upvotes: 0