Skip to content
Latchkey

Gradle "BUILD FAILED" - Read the Failing Task in CI

BUILD FAILED is Gradle's summary banner, not a diagnosis. The actual cause is in the What went wrong: section just above it, which names the failing task and the underlying error.

What this error means

The log ends with BUILD FAILED in Ns preceded by * What went wrong: and Execution failed for task ':module:taskName'. The failing task tells you the phase -- compile, test, checkstyle, jar -- so you know where to look.

gradle
* What went wrong:
Execution failed for task ':app:compileJava'.
> Compilation failed; see the compiler error output for details.

BUILD FAILED in 8s

Common causes

A specific task failed

The Execution failed for task line names the task. compileJava means a compile error, test means a failing test, checkstyleMain means a lint violation -- each has its own detail above the banner.

Misconfigured build script or plugin

A bad plugin version, a missing toolchain, or an invalid build.gradle setting can fail the build during configuration before any task runs.

How to fix it

Re-run with --stacktrace and read the task

  1. Note the task named in Execution failed for task.
  2. Re-run with ./gradlew <task> --stacktrace --info to surface the full cause.
  3. Fix the underlying error (compile, test, lint) for that specific task.
Terminal
./gradlew build --stacktrace --info

Validate the build configuration

  1. Run ./gradlew help to confirm the scripts configure without error.
  2. Check plugin and toolchain versions match what the runner provides.
  3. Use --scan for a shareable diagnostic of the failing run.

How to prevent it

  • Always read What went wrong and the named task, not just the BUILD FAILED banner.
  • Use the Gradle wrapper so CI and local use the same Gradle version.
  • Run ./gradlew build locally before pushing to catch task failures early.

Frequently asked questions

What causes ""BUILD FAILED""?
The Execution failed for task line names the task. compileJava means a compile error, test means a failing test, checkstyleMain means a lint violation -- each has its own detail above the banner.
How do I fix "BUILD FAILED"?
Re-run with --stacktrace and read the task

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card