Skip to content
Latchkey

Cordova "Error code 1 for command: gradlew" in CI

cordova build android runs the native ./gradlew wrapper. When Gradle exits non-zero, Cordova prints "Error code 1 for command: ...gradlew" plus the arguments. That line is just the relay; the actual failure (compile, manifest, SDK) is in the Gradle output above it.

What this error means

cordova build android ends with "(node:...) Error: ... Command failed with exit code 1: ...gradlew" or "Error code 1 for command: /path/gradlew".

Cordova
BUILD FAILED in 1m 2s
Error code 1 for command: /home/runner/work/app/platforms/android/gradlew
with args: cdvBuildDebug,-b,...

Common causes

A Gradle task failed underneath Cordova

Cordova forwards Gradle's exit code. A failing compile, resource merge, or missing SDK component makes gradlew exit 1.

Toolchain mismatch (JDK, Gradle, AGP)

An unsupported JDK or Gradle version for the project causes Gradle to abort with exit code 1.

How to fix it

Read the Gradle failure above the relay line

  1. Scroll up to the Gradle FAILURE block for the real cause.
  2. Reproduce by running the wrapper directly with --stacktrace.
  3. Fix the underlying task, then re-run cordova build.
Terminal
cd platforms/android
./gradlew cdvBuildDebug --stacktrace

Fix the toolchain versions

Provision the JDK and Gradle that cordova-android and the AGP require so the wrapper can complete.

.github/workflows/ci.yml
- uses: actions/setup-java@v4
  with: { distribution: temurin, java-version: '17' }

How to prevent it

  • Always read Gradle output above the Cordova relay error.
  • Provision matching JDK, Gradle, and AGP versions.
  • Run the gradlew task directly in CI for full logs.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →