Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gostrafx/79c8f2849ae5123dd8614aa0a3606b75 to your computer and use it in GitHub Desktop.
Save gostrafx/79c8f2849ae5123dd8614aa0a3606b75 to your computer and use it in GitHub Desktop.
Fixing: Gradle Build Error Unity Version 2021 And 2020
Fixing: Gradle build failed. See the Console
Fixing: A failure occurred gradle.internal.tasks.Workers$ActionFacade - Admob Unity
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 later

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.1 and earlier

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:

  1. Enable custom Gradle templates

Go to Project Settings > Player > Android > Publishing Settings > Build, and select:

  • Custom Base Gradle Template
  1. 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**
          }
      }
  }
  1. 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.
Install Gradle

Download Gradle version 6.7.1.

Set Gradle path in Unity

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment