Apache Cordova: Create a signed release APK – Easy HowTo

To upload an app to the Google Play Store, you need to sign it first.

There are a lot of tutorials out there, some of which are simply overwhelming, to say the least.


Here is my very simple solution to create a signed APK which you can upload to the Play Store.

Hate reading? The tl;dr version is at the bottom of the page.

To make it clear: This has been tested with Apache Cordova version 7.0.1.
To check which version of Cordova you are using, run this on your console.

Step 1: Create a keystore file

First: Navigate to your app’s root folder. Then you run the following command, after editing it to suit you environment.

Here, you will create a keystore file for your project. This file is needed to sign the APK. Simply change the Keystore filename to something you like, and do the same with the alias at the end of the comand.

After hitting enter, you will be presented with a few questions which you need to answer.

After you are done with this, the keystore file will be created in your app’s root directory. Simple move it to the platforms/android  directory.

Caution

If you do not create the keystore file, your build will crash with the following error message:

Step 2: Create release-signing.properties file

Create a file in your platforms/android/  directory with the name release-signing.properties .

Put the following content into the file

Rename the properties with the ones you provided during your keystore file generation and save the file.

Step 3: Run cordova build

To create your signed APK file, simply run the following command (still in your app’s root directory)

Now Cordova will use your release-signing.properties  file and create a signed APK without any hassle.

After the process has finished, you should be presented with something like this:

tl;dr : Breaking it down – all in one

Here’s the tl;dr for all the people who don’t want to read all this stuff above.
Replace the options with your own.

  1. keytool -genkey -v -keystore MyApp.keystore -alias myapp
  2. mv MyApp.keystore platforms/android
  3. Create the file  platforms/android/release-signing.properties
  4. Insert the following and replace the bold formatted properties with your own
  5. cordova build android --release

You’re done :)

Extend the validity of the signed APK.

Sometimes while uploading the APK to the Play Store, you get the error which says

You uploaded an APK signed with a certificate that expires too soon. You need to sign your APK with a certificate that expires farther into the future.

So what to do? Well, you create an APK which expires further in the future. To do so, simply add the following to your command

This will set the expiration of your signature to more than 50 years. So all together, your command now looks like

Got something to add?

Let me know in the comments :)

Apache Cordova: Create a signed release APK – Easy HowTo
Wie bewertests Du diesen Beitrag? Rate this postplease.

Kommentar verfassen