Unity Android Gradle Build Failed
Quick answer
Gradle build errors in Unity Android builds usually come from mismatched JDK, SDK, or Gradle versions, duplicate libraries between plugins, or a custom Gradle template. Use the Hub-installed Android tools and read the Gradle error text.
Most likely fix: Use the Unity-installed Android tools
How to fix it
Try these in order — the most common fix is first.
1. Use the Unity-installed Android tools
- Open Edit > Preferences > External Tools (Unity > Settings on macOS)
- Tick the 'Installed with Unity (recommended)' boxes for JDK, SDK, NDK, and Gradle
- Reinstall Android Build Support from Unity Hub if they are missing
Did this fix it?2. Read the real Gradle error
- Open Editor.log and search for 'FAILURE: Build failed' or 'What went wrong'
- Fix the dependency or class named there
Did this fix it?3. Resolve duplicate libraries
- Use External Dependency Manager: Assets > External Dependency Manager > Android Resolver > Force Resolve
- Remove duplicate .aar or .jar files from Assets/Plugins
Did this fix it?4. Reset custom Gradle templates
- Open Project Settings > Player > Android > Publishing Settings
- Untick custom Gradle template options, rebuild, and re-add only what you need
Did this fix it?5. Set API levels
- Check Project Settings > Player > Other Settings for Minimum and Target API level against current Google Play requirements
Did this fix it?
Symptoms
Console shows 'CommandInvokationFailure: Gradle build failed', 'Failed to install the following Android SDK packages', or duplicate class errors.
Why it happens
- Android SDK, NDK or JDK pointing to a custom install instead of the Unity-bundled one
- Gradle or Android Gradle Plugin version mismatch with the Unity version
- Duplicate classes from multiple plugins (for example Firebase or ads SDKs)
- Wrong minimum or target API level
- Old custom Gradle templates
This guide also covers
- unity gradle build failed
- unity android build failed
- commandinvokationfailure gradle build failed
- unity duplicate class gradle
Still not working?
If Unity keeps failing, you're not alone. See every Unity problem users report or the alternatives people switch to.
Have an app idea? Our small team builds any software: web and mobile apps, games, desktop, AI tools. Price agreed together.
Talk to us