Skip to content

Instantly share code, notes, and snippets.

@hdodov
Last active June 13, 2017 09:47
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save hdodov/b32bd2d293067106be30edd2ff3197c0 to your computer and use it in GitHub Desktop.
In-depth, step-by-step guide to building a Cordova release APK in Windows.
  1. Open CMD as administartor
  2. Go to your JDK's bin folder:
C:\Program Files\Java\jdk1.8.0_121\bin
  1. Run:
keytool -genkey -v -keystore C:\myKeystoreName.keystore -alias myName -keyalg RSA -keysize 2048 -validity 10000
  1. Add a build.json file to your Cordova folder (where the platforms and www folders reside). It should look like this:
{
    "android": {
        "release": {
            "keystore": "C:\\myKeystoreName.keystore",
            "storePassword": "password_youve_set",
            "alias": "myName",
            "password" : "alias_password_youve_set",
            "keystoreType": ""
        }
    }
}
  1. Open CMD
  2. Go to your Cordova folder (where build.json is located)
  3. Run:
cordova build android --release --buildConfig build.json
  1. Go to:
yourCordovaFolder\platforms\android\build\outputs\apk
  1. There should be a file, named android-release.apk. That's your file.

Conclusion

The .keystore file is a container of certificates, private keys, etc. In this case, it stores a self-signed certificate, which is:

an identity certificate that is signed by the same entity whose identity it certifies

You'll use it in all your future builds of the app, so save it somewhere safe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment