Fixing: Unity Gradle - A Failure Occurred While Executing com.android.build.gradle.internal.tasks.Worker
Fixing: A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
Unity version | * | Gradle version | Android Gradle Plug-in version |
---|---|---|---|
2023.2 | Admob | 7.6 | 7.3.1 |
2022.3 | Admob | 7.2 | 7.1.2 Or 7.1.3 |
2021.3, 2020.3 replace Gradle | Admob | 6.7.1 | 4.2.0 |
2021.3, 2020.3 | Error : Admob or Compiling | 6.1.1 | 4.0.1 |
The Google Mobile Ads Android SDK 22.4.0
added a <property>
element in its Android manifest. Building against this version or higher requires using Gradle 6.7.1 or higher and Android Gradle plugin 4.2.0 or higher. This guide instructs you on how to make sure your Unity editor is compatible.
Complete the Get started guide. Make sure to:
- Set Minimum API level to 21
- Set Target API level to 33 or 34 or higher
- Enable Custom Main Gradle Template and Custom Gradle Properties Template settings
Unity 2022.2 and higher comes with newer versions of Gradle for Android by default. No additional action is required to support Google Mobile Ads Android SDK 22.4.0.
Unity 2022.2 and earlier use an older version of Gradle for Android which is not supported by Google Mobile Ads Android SDK 22.4.0. The following steps show how to upgrade to the minimally required Gradle version based on your build process:
- Enable custom Gradle templates
Go to Project Settings > Player > Android > Publishing Settings > Build, and select:
- Custom Base Gradle Template
- Modify Base Gradle Template
Open the Assets/Plugins/Android/baseProjectTemplate.gradle file and set the dependencies to use Gradle build tools 4.2.0.
allprojects {
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
**BUILD_SCRIPT_DEPS**
}
}
}
Replace to
allprojects {
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:4.2.0'
**BUILD_SCRIPT_DEPS**
}
}
}
- Update Gradle Update your Gradle version to 6.7.1. The steps for this are slightly different depending on whether you export your project as an Android Studio project as part of your build process.
Download Gradle version 6.7.1.
In Unity, open Unity Preferences > External Tools and set the custom Gradle path.
For Unity 2021.3 replace Gradle 6.1.1 to 6.7.1
Key Point: We recommend using Gradle 6.7.1 to minimize the chance of the Gradle update introducing other build errors in your project.