Cordova Sign Android build with Cordova 5 Add the build configuration to sign the .apk file

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

  1. Add a keystore using:

    keytool -genkey -v -keystore example.keystore -alias example -keyalg RSA -keysize 2048 -validity 10000 
    

Note: This should be at root of project. Though not a hard requirement, it eases the file referencing

  1. Add a build.json with release/dev configuration for keystore, at the root of project:

    {
      "android": {
        "debug": {
          "keystore": "..\android.keystore",
          "storePassword": "android",
          "alias": "mykey1",
          "password" : "password",
          "keystoreType": ""
        },
        "release": {
          "keystore": "..\android.keystore",
          "storePassword": "",
          "alias": "mykey2",
          "password" : "password",
          "keystoreType": ""
        }
      }
    }
    
  2. Add the --buildConfig switch to Cordova/ Ionic build command:

    cordova build android --release --buildConfig=build.json
    

or with Ionic as

  ionic build android --release --buildConfig=build.json

The signed file will be generated under the new folder structure at

/platforms/android/build/outputs/apk/android-release.apk


Got any Cordova Question?