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-
- Download Android Studio and install
- Open Android Studio
- Open
File->Project Structure->SDK Location - Copy Android SDK location
ExampleC:\Users\<user_name>\AppData\Local\Android\Sdk
JAVA_HOME-
- Download JDK 11 (required version) and install
- Copy JDK location
ExampleC:\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
- Open
System Properties - Open
Advancedtab - Click
Environment Variablesbutton - On
System Variablessection, clickNew - Input
Variable nameandVariable value - 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.
-
Add new
Pathvalue inSystem Variablesto exposeapksignerExampleC:\Users\<user_name>\AppData\Local\Android\Sdk\build-tools\34.0.0 -
Open
Terminaland runapksignerExampleapksigner verify --verbose --print-certs <file_name>.apk