To generate a release build for Android, we can use the following cordova cli command,
$ cordova build --release android
we can find our unsigned APK file in platforms/android/build/outputs/apk.Now, we need to sign the unsigned APK and run an alignment utility on it to optimize it and prepare it for the app store.Let’s generate our private key using the keytool command that comes with the JDK.
$ keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000
You’ll first be prompted to create a password for the keystore. Then, answer the rest of the nice tools’s questions and when it’s all done, you should have a file called my-release-key.keystore created in the current directory.
To sign the unsigned APK, run the jarsigner tool which is also included in the JDK with the following command,
$ jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore HelloWorld-release-unsigned.apk alias_name
This signs the apk in place. Finally, we need to run the zip align tool to optimize the APK. The zipalign tool can be found in /path/to/Android/sdk/build-tools/VERSION/zipalign.use this command to zipalign the apk,
$ zipalign -v 4 HelloWorld-release-unsigned.apk HelloWorld.apk
Now we have our final release binary called HelloWorld.apk and we can release this on the Google Play Store for all the world to enjoy!