Quick answer: Read the actual Gradle error in the build log, align the SDK, JDK, and Gradle versions in External Tools, resolve duplicate or conflicting libraries, and bump minSdk or fix the manifest as the log indicates.
“Gradle build failed” is a wrapper around dozens of specific errors — the message in the Console is useless on its own. The real cause is buried in the Gradle output. Here is how to find and fix the usual ones.
How to fix it
1. Find the real error in the build log
The Console line is generic; open the full build log (or build from the command line with stacktrace) and search for the first line containing “error” or “FAILED”. That line names the actual problem — a missing class, a duplicate resource, a version conflict.
2. Align SDK, NDK, JDK, and Gradle versions
In Preferences, External Tools, let Unity manage these or point them at compatible versions. Mismatches here cause the majority of Gradle failures; using the Unity-recommended versions resolves them.
3. Resolve dependency and manifest conflicts
Two plugins pulling different versions of the same library, or a duplicate permission in the manifest, fail the build. Use the External Dependency Manager to resolve versions and remove duplicate manifest entries.
Catching the ones you can't reproduce
The hardest version of this to fix is the one you can't reproduce — it only happens on a player's hardware, OS, driver, or save state, under conditions that simply aren't present on your machine. A report that says “it crashed” or “it froze” gives you nothing to act on, so the bug survives release after release while quietly costing you players.
Automatic error capture closes that gap. Each failure arrives with its full stack trace, the device and OS, the build number, and a breadcrumb trail of what the player did right before it broke, so even a failure you have never seen becomes a specific, reproducible issue. Fold identical failures into one signature ranked by how many players each hits, and your worklist sorts itself worst-first instead of arriving as a stream of vague complaints.
This is where a tool like Bugnet earns its place. Its SDK captures every Unity error automatically with the full stack trace plus device, OS, memory, build, and game-state context, folds duplicates into one grouped issue with an occurrence count, and ties each to the build it first appeared on — so you fix the problem that hurts the most players first and confirm it is gone when its signature disappears from the next release.
The bug you can't reproduce isn't gone — it's just invisible until you capture it from the player's device.