Android build failures in Unity Build Automation often result from incompatible Android tools like JDK, SDK, or Gradle versions. The Editor runs in batchmode using default Android tools, and errors typically show "Gradle Build failed." To resolve, ensure local batchmode builds use the same Unity Editor, JDK, SDK, and Gradle versions as the automation service. If issues persist despite matching versions, contact support for further help.
Symptoms
- My Android builds are failing, and I'm not sure why
- My Android builds are failin,g and other targets are building correctly
- My Android builds are failing in UB,A but work locally
Cause
Unity Build Automation runs the Editor in batch mode to execute your builds and uses the default Android tools (JDK/SDK) to complete them. When your Android build fails in the service but works locally or other targets seem to be working correctly, the root cause is often incompatible Android tools.
Failures due to Android tools will often have the message: "Gradle Build failed" in the logs. Gradle is the build system used by Unity for Android builds.
Resolution
The first step is to ensure you can build your project locally in batch mode using the same version of the Unity Editor, the JDK (the default version that ships with the chosen version of the Editor), and the Android SDK (either the default version or as specified in your advanced target configuration). You should also validate the version of Gradle you are using.
If your project builds locally, note the versions of the tools used and ensure they match the versions you are using in the Unity Build Automation service. To check your local version of Gradle, use the command "gradle—-version" in the terminal.
If your build works locally in batchmode with the same tools and versions you are attempting to use with the Unity Build Automation service but continues to fail in the service, please open a support ticket so our team can investigate further.
More Information