Cordova build release Android with signed apk

cordova build release android

It seems so strange but releasing and signing the Android app with Cordova is not really obvious. In this post I will explain how to sign it without any troubles.

So, there is a well-known command to build and release an Android application:

cordova build --release android

But what is interesting, if you run it without any preparation, you would see this output:

BUILD SUCCESSFUL

Total time: 11.587 secs
Built the following apk(s):
        C:/PATH_TO_YOUR_APP/platforms/android/build/outputs/apk/android-release-unsigned.apk

This output tells you that the .apk file was successfully built. But if you look at its name, you would see that this file is unsigned. And you know that before publishing the app to Google Play every app should be signed with a keystore file.

Signing the apk while running “cordova build –release android”

After hours spent on googling and experimenting I finally found a lovely solution. For successful signing the apk during build –release command execution you should create release-signing.properties file and put it into platforms/android.

This file should contain the key parameters for the signing, such as:

  • storeType
  • storeFile
  • keyAlias
  • keyPassword
  • storePassword

Release-signing.properties file example

This is the example of release-signing properties filled by placeholders:

storeFile=PATH_TO_YOUR_KEYSTORE_FILE
storeType=jks
keyAlias=YOUR_ALIAS
// if you don't want to enter the password at every build, you can store it with this
keyPassword=KEY_PASSWORD
storePassword=STORE_PASSWORD

Now when you run cordova build –release android this setting will enable the signing process and in the end you should see this output:

Built the following apk(s):
        C:/PATH_TO_YOUR_APP/platforms/android/build/outputs/apk/android-release-unsigned.apk
        C:/PATH_TO_YOUR_APP/platforms/android/build/outputs/apk/android-release.apk

The android-release.apk is the file that you need for publishing the app in the Google Play store.

 

Leave a Reply

2 Comments on "Cordova build release Android with signed apk"


Guest
nanonymous peter
1 year 25 days ago

so nice worked for me

Guest
Davor
1 year 29 days ago

Great tutorial!! Thanks