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.
* What went wrong:
Execution failed for task ':app:compileJava'.
> Compilation failed; see the compiler error output for details.
BUILD FAILED in 8sCommon 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
- Note the task named in
Execution failed for task. - Re-run with
./gradlew <task> --stacktrace --infoto surface the full cause. - Fix the underlying error (compile, test, lint) for that specific task.
./gradlew build --stacktrace --infoValidate the build configuration
- Run
./gradlew helpto confirm the scripts configure without error. - Check plugin and toolchain versions match what the runner provides.
- Use
--scanfor a shareable diagnostic of the failing run.
How to prevent it
- Always read
What went wrongand the named task, not just theBUILD FAILEDbanner. - Use the Gradle wrapper so CI and local use the same Gradle version.
- Run
./gradlew buildlocally before pushing to catch task failures early.