Hackernoon logoHow to Sign Android APKs with Apache Cordova: A Brief Guide by@codechem

How to Sign Android APKs with Apache Cordova: A Brief Guide

Author profile picture


Diligent coding, creative thinking, transparent working. We’ve mastered the custom software development.

In order to submit an app to the Google Play Store, you need to sign the apk no matter what development framework you're using. In this article, we'll learn how to sign an apk using Cordova. Before starting we will assume that we have previously made all the necessary Cordova installations and added an android platform for our project.

Create a keystore file

First, we'll need to create the keystore file which is basically a binary file that can hold a set of keys. To create this file you'll need to go to the root of your project and run the command below:

keytool -genkey -v -keystore myapp.keystore -alias myappalias -validity 10000


 tag stands for the expiration of the key. After running this command you will see the 
 file at the root of your project.

Create a build.json file


 file also needs to be created at root level and this is the place where we will store all the parameters needed for signing. The file needs to look something like this:

    "android": {
        "debug": {
            "keystore": "./myapp.keystore",
            "storePassword": "pass",
            "alias": "myappalias",
            "password" : "pass",
            "keystoreType": "jks"
        "release": {
            "keystore": "/myapp.keystore",
            "storePassword": "pass",
            "alias": "myappalias",
            "password" : "pass",
            "keystoreType": "jks"

Set version and package name

Next, we need to do is open the 

 file at root level where we can set the version, version code, and package name in the
 tag at the top of the file.

<widget android-versionCode="10" defaultlocale="en-US" id="com.example.myapp" version="1.0" ...>
  • versionCode
     is used only for calculations by Google Play and is not visible for users
  • id
     is the package name of your app
  • version
     is the version of your app that will be visible on Google Play

Building the app

The last thing that we want to do is build the app using the parameters that we defined in 

. We will achieve that by adding the flag
 to the build command:

cordova build android --release --buildConfig

This command will build a signed apk that you can upload to Google Play. The location of the apk will be written as an output of the command, but the correct location should

be platforms/android/app/build/outputs/apk/release

For more details on the installation, building, and signing you can go to the official Cordova Android Platform Guide

Previously published at https://blog.codechem.com/signing-android-apk-with-apache-cordova


Join Hacker Noon

Create your free account to unlock your custom reading experience.