GRADLE BUILD FAILED & MANIFEST MERGER ERROR
UnityEditor.BuildPlayerWindow+BuildMethodException: Gradle build failed. See the Console for details.
What Is the Error?
Gradle is the build automation tool used by Android to resolve third-party plugins (Google Play Services, AdMob, In-App Purchasing, Firebase), merge XML manifests, and assemble the final .aab or .apk package.
When two plugins import conflicting versions of the same Android library (e.g. androidx.core), or when multiple AndroidManifest.xml files declare conflicting android:theme attributes, the Gradle merger halts the build with an error.
Step-by-Step Resolution
- Enable Custom Base Gradle Template:
Go to Project Settings > Player > Android > Publishing Settings. Under Build, check:
• Custom Main Gradle Template (mainTemplate.gradle)
• Custom Gradle Properties Template (gradleTemplate.properties) - Enable AndroidX & Jetifier in gradleTemplate.properties:
Open
Assets/Plugins/Android/gradleTemplate.propertiesand add the following flags to automatically migrate legacy support libraries:android.useAndroidX=true android.enableJetifier=true - Run External Dependency Manager (EDM4U) Force Resolve:
If using Google Mobile Ads or Firebase, go to Assets > External Dependency Manager > Android Resolver > Force Resolve. This deduplicates overlapping .aar dependencies.
- Enable Minify (ProGuard / R8) with Custom Keep Rules:
If the dex limit (64k methods) is exceeded, enable Custom Proguard File in Publishing Settings.
Related Troubleshooting Guides
Related Guides
Other Build Errors
Frequently Asked Questions
D:/Projects/Game/ to avoid Gradle path truncation bugs.