Skip to content

Setup Cordova on Windows

Preparing Environment Variables for Android Development

Environment variables are required to build apps using the Command Line Interface (CLI).

Variable Description
ANDROID_HOME Android SDK location
JAVA_HOME Java SDK location
Get value on Windows
ANDROID_HOME
  1. Download Android Studio and install
  2. Open Android Studio
  3. Open File -> Project Structure -> SDK Location
  4. Copy Android SDK location
    Example
    C:\Users\<user_name>\AppData\Local\Android\Sdk
    
JAVA_HOME
  1. Download JDK 11 (required version) and install
  2. Copy JDK location
    Example
    C:\Program Files\Java\jdk-11
    

Compatible Version

If you are developing a Cordova project alongside CapacitorJS, then please use JDK 17.

Set value on Windows
  1. Open System Properties
  2. Open Advanced tab
  3. Click Environment Variables button
  4. On System Variables section, click New
  5. Input Variable name and Variable value
  6. Click OK

Generating a build

To build for debuging (apk):

Example
cordova build android

To build for release (aab):

Example
cordova build android --release

How to verify a build

To ensure there are no errors when submitting your app to the store, its strongly recommended to verify the build. The verify result is sometimes necessary for penetration testing requirements.

  1. Add new Path value in System Variables to expose apksigner

    Example
    C:\Users\<user_name>\AppData\Local\Android\Sdk\build-tools\34.0.0
    

  2. Open Terminal and run apksigner

    Example
    apksigner verify --verbose --print-certs <file_name>.apk
    

References