"We recommend using a newer Android Gradle plugin to use compileSdk = 34". How to solve?

Hello, I need to use target API 34 for Google Play.

In project I have:
AdMob 9.2.0
Google Play Games Plugin 0.11.01
External Dependency Manager 1.2.181

I tested on:
2022.3.42f1
2022.3.41f1
2022.3.40f1
2022.3.22f1
No result

Text of errors:

WARNING:We recommend using a newer Android Gradle plugin to use compileSdk = 34

This Android Gradle plugin (7.4.2) was tested up to compileSdk = 33

This warning can be suppressed by adding
android.suppressUnsupportedCompileSdk=34
to this project’s gradle.properties

The build will continue, but you are strongly encouraged to update your project to
use a newer Android Gradle Plugin that has been tested with compileSdk = 34

CommandInvokationFailure: Gradle build failed.
D:\Unity\2022.3.42f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath “D\Unity\2022.3.42f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-7.5.1.jar” org.gradle.launcher.GradleMain “-Dorg.gradle.jvmargs=-Xmx4096m” “bundleRelease”

I tried:

  1. Change to gradle 8.1.1 and 8.10 - not help.
  2. android.suppressUnsupportedCompileSdk=34 - not help.
  3. AdMob v9.1.1 - not help.

Observations
Without AdMob it builds without problems, but I can’t not use AdMob

i am also facing this problem. I have tried all the options. but not working. i installed various versions…
There is no exact solutions… Only unity persons can answer this… i am trying for past 20 days… I have used chatgpt, gemini,and google and tried various options. but same error happens.

coud UNITY TECHNOLOGIES peoples can answer this questions… many peoples are receiving the same error.

i am so disappointed… could any one help me to solve this error.

i am not using any admob… without admob aslo i am receiving this gradlebuild error. i am using unity 2020.3.45f1…

Post full error message, where the build actually fails

OWS\system32\cmd.exe
AMPLITUDE_API_KEY = 28f3cae0b33b8b3702120c9ed1a935aa
LOGONSERVER = \DESKTOP-8EGCT80
PSModulePath = C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules;C:\Program Files (x86)\AWS Tools\PowerShell
PUBLIC = C:\Users\Public
SystemRoot = C:\WINDOWS
NUMBER_OF_PROCESSORS = 8
WOOTRIC_CLIENT_TOKEN = NPS-aa8be4c3
JAVA_TOOL_OPTIONS = -Dfile.encoding=UTF-8
DEBUG_ENV_VAR = UnityHub
TMP = C:\Users\ADMIN\AppData\Local\Temp
AMPLITUDE_TOKEN_YELLOWBUCKET_PROD = UYDQtPOw83dIfVy3SrW5oMyo7ru4PRkV
FPS_BROWSER_APP_PROFILE_STRING = Internet Explorer
TEMP = C:\Users\ADMIN\AppData\Local\Temp
Path = C:\Program Files\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files\PuTTY;C:\Users\ADMIN\AppData\Local\Programs\Python\Python312\Scripts;C:\Users\ADMIN\AppData\Local\Programs\Python\Python312;C:\Users\ADMIN\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\Scripts
USERNAME = ADMIN
COMPUTERNAME = DESKTOP-8EGCT80
AMPLITUDE_API_KEY_REDBUCKET_PROD = ca12bb461ea96f9bdf5df4ded7d52994
AMPLITUDE_API_KEY_YELLOWBUCKET_PROD = e03a9bbe92dc38a88cdb068d24c65b46
PATHEXT = .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
ALLUSERSPROFILE = C:\ProgramData
SystemDrive = C:
windir = C:\WINDOWS
AMPLITUDE_TOKEN_REDBUCKET_PROD = jTIgKs5KTZOjiqEEVdZFbgo_VRhABduL
FPS_BROWSER_USER_PROFILE_STRING = Default
AMPLITUDE_TOKEN_GREENBUCKET_DEV = 84H2gMm_FJzhr3mBaX1lM1JVukmCM7d9
AMPLITUDE_API_KEY_STAGING = 83ee04fccc67e4fcc7dd527c4c6f1e21
CommonProgramFiles(x86) = C:\Program Files (x86)\Common Files
APPDATA = C:\Users\ADMIN\AppData\Roaming
DriverData = C:\Windows\System32\Drivers\DriverData
PROCESSOR_LEVEL = 6
CommonProgramW6432 = C:\Program Files\Common Files
ProgramFiles(x86) = C:\Program Files (x86)
SESSIONNAME = Console
AMPLITUDE_TOKEN_YELLOWBUCKET_DEV = wKi8foVigDditGFvmZewRFWsEbX9Y0YO
AMPLITUDE_API_KEY_YELLOWBUCKET_DEV = 48835b4d1f5e342aefe5f016324d296a
LOCALAPPDATA = C:\Users\ADMIN\AppData\Local
HOMEPATH = \Users\ADMIN
ProgramData = C:\ProgramData
HOMEDRIVE = C:
USERDOMAIN_ROAMINGPROFILE = DESKTOP-8EGCT80
AMPLITUDE_DEPLOYMENT_KEY_RED_BUCKET_PROD = client-zH8Y7OK1i331EKuG77C6UxN8ygcM6LzS
ORIGINAL_XDG_CURRENT_DESKTOP = undefined

stderr[

FAILURE: Build failed with an exception.

  • Where:
    Build file ‘D:\FooyaAndroid06-08-24\fooyaiostoandroidbuilderror9\fooyaandtoios\Temp\gradleOut\unityLibrary\build.gradle’ line: 79

  • What went wrong:
    Could not compile build file ‘D:\FooyaAndroid06-08-24\fooyaiostoandroidbuilderror9\fooyaandtoios\Temp\gradleOut\unityLibrary\build.gradle’.

startup failed:
build file ‘D:\FooyaAndroid06-08-24\fooyaiostoandroidbuilderror9\fooyaandtoios\Temp\gradleOut\unityLibrary\build.gradle’: 79: unexpected token: in @ line 79, column 5.
in that addorg.gradle.jvmargs=-XmxM
^

1 error

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 1s
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
]
stdout[

Configure project :launcher
WARNING: The option setting ‘android.enableR8=false’ is deprecated.
It will be removed in version 5.0 of the Android Gradle plugin.
You will no longer be able to disable R8
]
exit code: 1
UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <22b0bbbaead14b9cb1b4d2a9a9cd4275>:0)
UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <22b0bbbaead14b9cb1b4d2a9a9cd4275>:0)
UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <22b0bbbaead14b9cb1b4d2a9a9cd4275>:0)
UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action1[T] progress, System.String error) (at <22b0bbbaead14b9cb1b4d2a9a9cd4275>:0) UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action1[T] progress) (at <22b0bbbaead14b9cb1b4d2a9a9cd4275>:0)
Rethrow as GradleInvokationException: Gradle build failed
UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action`1[T] progress) (at <22b0bbbaead14b9cb1b4d2a9a9cd4275>:0)
UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <22b0bbbaead14b9cb1b4d2a9a9cd4275>:0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <22b0bbbaead14b9cb1b4d2a9a9cd4275>:0)
Rethrow as BuildFailedException: Exception of type ‘UnityEditor.Build.BuildFailedException’ was thrown.
UnityEditor.Android.PostProcessor.CancelPostProcess.AbortBuild (System.String title, System.String message, System.Exception ex) (at <22b0bbbaead14b9cb1b4d2a9a9cd4275>:0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <22b0bbbaead14b9cb1b4d2a9a9cd4275>:0)
UnityEditor.Android.PostProcessAndroidPlayer.PostProcess (UnityEditor.BuildTarget target, System.String stagingAreaData, System.String stagingArea, System.String playerPackage, System.String installPath, System.String companyName, System.String productName, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at <22b0bbbaead14b9cb1b4d2a9a9cd4275>:0)
UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <22b0bbbaead14b9cb1b4d2a9a9cd4275>:0)
UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, System.String installPath, System.String companyName, System.String productName, System.Int32 width, System.Int32 height, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at <683db824f2154b7c9f84bd4e86ddfe9f>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

I have attached the error file in notepad also.
builderror.txt (6.7 KB)

Seems that your build.gradle is incorrect. Can you share it, so that I can take a look what’s wrong? Or you can recreate your templates. Back up whatever templates you have, delete these from the project and check needed templates in Player->Publishing settings

Hello, you error looks different from my. I just googled you “WARNING: The option setting ‘android.enableR8=false’ is deprecated” and get answer:


(Set “Use R8” = true)

My logs from issue (title of topic):
error 1.txt (9.4 KB)
error 2.txt (16.1 KB)
error 3.txt (7.5 KB)

Topic is actual.

Without AdMob 9.2.0 it make build project. Help, please!

I’d need a repro project to check. Only guess I have - try updating EDM4U version to the latest. And setting Min Target API to 24

I got 2 errors instead 3, but “WARNING:We recommend using a newer Android Gradle plugin to use compileSdk = 34” - not gone.

Unity 2022.3.42f1
External Dependency Manager v1.2.182
Min API 24
Target API - 34
error 1.txt (7.5 KB)
error 2.txt (15.6 KB)

I’am preparing repro project

Repro project ready (Unity 2022.3.42f1)
Error Window
error 1.txt (6.3 KB)
error 2.txt (14.3 KB)
MobileProjectTest.zip (2.7 MB)

That’s warning, not error. You can ignore that.
For the failure - did you try resolving dependencies using new EDM4U?

Ignoring not help

error 1.txt (9.8 KB)
error 2.txt (2.3 KB)
error 3.txt (16.1 KB)

I resolved with new EDM4U, but it not build

I’m not sure, looks like either EDM4U or Google Play Games Plugin issue. Somehow it’s location is resolved to
file:/E:/Game development/Games/MobileProjectTest/Packages/com.google.play.games/Editor/m2repository/com/google/games/gpgs-plugin-support/0.11.01/gpgs-plugin-support-0.11.01.pom
While it’s not in the packages.
As a temp workaround - you can manually modify path here in your settingsTemplate.gradle:

 maven {
            url (unityProjectPath + "/Packages/com.google.play.games/Editor/m2repository") // Assets/GooglePlayGames/com.google.play.games/Editor/GooglePlayGamesPluginDependencies.xml:11
        }

Something like this should work:

 maven {
            url (unityProjectPath + "/Assets/GooglePlayGames/com.google.play.games/Editor/m2repository") // Assets/GooglePlayGames/com.google.play.games/Editor/GooglePlayGamesPluginDependencies.xml:11
        }

Update: That’s actually Google Play Games plugin issue.
“\Assets\GooglePlayGames\com.google.play.games\Editor\GooglePlayGamesPluginDependencies.xml” states that plugin repo is at

<repository>Packages/com.google.play.games/Editor/m2repository</repository>

While it is actually at

<repository>Assets/GooglePlayGames/com.google.play.games/Editor/m2repository</repository>

It builds successfully in repro project. So, I try in main project and write here about result.

It builds successfully in main project too!
You Unity’s Jesus! Thanks so much!

I was having the same issue until I changed the Min Api Level To 24

Updating EDM4U to latest version and setting Min Target API 24 solves all my issues!