JAVA_HOME and PATH

JAVA_HOME, ANDROID_HOME and the PATH

Cordova 129 finds the toolchain through three settings. JAVA_HOME names the JDK that runs Gradle 19,597 ; ANDROID_HOME names the SDK root (the older ANDROID_SDK_ROOT is deprecated); and the PATH must reach sdkmanager, avdmanager, adb, emulator and a system gradle. Android Studio 234 's Gradle JDK setting does not apply: when Gradle runs from a terminal, as under the Cordova CLI, JAVA_HOME decides. On Linux and macOS, put the exports in ~/.bashrc or ~/.zshrc, then let Cordova check them from inside a project. This run started from a shell with no Android settings at all:

The environment Cordova needs, checked by cordova requirementsShell
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
export ANDROID_HOME=/opt/android-sdk
PATH="$JAVA_HOME/bin:/opt/gradle/bin:$PATH"
PATH="$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools:$PATH"
export PATH="$ANDROID_HOME/emulator:$PATH"
cordova requirements android
Output
Requirements check results for android:
Java JDK: installed 17.0.20
Android SDK: installed true
Android target: installed android-37.0,android-36
Gradle: installed /opt/gradle-9.7.1/bin/gradle

Without ANDROID_HOME, the check reports Failed to find 'ANDROID_HOME' environment variable and fails the target and Gradle lines too. Without JAVA_HOME it silently uses the first javac on the PATH, JDK 21 on this machine; on macOS it asks /usr/libexec/java_home, which returns the newest JDK, so pin it with export JAVA_HOME=$(/usr/libexec/java_home -v 17). On Windows, use Edit the system environment variables > Environment Variables: set ANDROID_HOME to C:\Users\<you>\AppData\Local\Android\Sdk, add its platform-tools, cmdline-tools\latest\bin and emulator folders plus a Gradle bin folder to PATH, and open a new terminal.