JAVA TOOL error on compile

I am getting these errors on compile:

Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
M:\WORK\_SGR\SGR\Library\Bee\Android\Prj\Mono2x\Gradle\unityLibrary\src\main\java\com\unity\androidnotifications\UnityNotificationManager.java:164: error: cannot find symbol
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU)
                                                        ^
  symbol:   variable TIRAMISU
  location: class VERSION_CODES
M:\WORK\_SGR\SGR\Library\Bee\Android\Prj\Mono2x\Gradle\unityLibrary\src\main\java\com\unity\androidnotifications\UnityNotificationManager.java:165: error: cannot find symbol
            permissionGranted = mContext.checkCallingOrSelfPermission(Manifest.permission.POST_NOTIFICATIONS) == PackageManager.PERMISSION_GRANTED;
                                                                                         ^
  symbol:   variable POST_NOTIFICATIONS
  location: class permission
Note: M:\WORK\_SGR\SGR\Library\Bee\Android\Prj\Mono2x\Gradle\unityLibrary\src\main\java\com\unity3d\player\UnityPlayerActivity.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors

FAILURE: Build failed with an exception.

* What went wrong:
[B][COLOR=#ff0000]Execution failed for task ':unityLibrary:compileReleaseJavaWithJavac'.[/COLOR][/B]
> Compilation failed; see the compiler error output for details.

* 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 2s

UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
CommandInvokationFailure: [B][COLOR=#ff0000]Gradle build failed[/COLOR][/B].
C:\Program Files\Unity\Hub\Editor\2022.3.7f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath "C:\Program Files\Unity\Hub\Editor\2022.3.7f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-7.2.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleRelease"

Environment Variables:
[COLOR=#ff0000][B]OculusBase = C:\Program Files\Oculus\[/B][/COLOR]
USERDOMAIN = POLYMAD-PC
ProgramFiles = C:\Program Files
TMP = C:\Users\PolyMad\AppData\Local\Temp
PROCESSOR_ARCHITECTURE = AMD64
PROCESSOR_REVISION = 5e03
OS = Windows_NT
CHROME_CRASHPAD_PIPE_NAME = \\.\pipe\crashpad_22868_JABSTVIIRYFECMSU
PROCESSOR_IDENTIFIER = Intel64 Family 6 Model 94 Stepping 3, GenuineIntel
AMPLITUDE_API_KEY = 28f3cae0b33b8b3702120c9ed1a935aa
USERPROFILE = C:\Users\PolyMad
JAVA_HOME = C:\Program Files\Unity\Hub\Editor\2022.3.7f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK
[B][COLOR=#ff0000]ADSK_3DSMAX_x64_2021 = C:\Program Files\Autodesk\3ds Max 2021\[/COLOR][/B]
DriverData = C:\Windows\System32\Drivers\DriverData
ComSpec = C:\WINDOWS\system32\cmd.exe
LAUNCH_DARKLY_CLIENT_TOKEN = 60a7e30fafc7e60e33446283
PSModulePath = C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
PUBLIC = C:\Users\Public
SystemRoot = C:\WINDOWS
HEAP_CLIENT_TOKEN = 1717415662
NUMBER_OF_PROCESSORS = 4
[B][COLOR=#ff0000]ADSK_3DSMAX_x64_2018 = C:\Program Files\Autodesk\3ds Max 2018\[/COLOR][/B]
WOOTRIC_CLIENT_TOKEN = NPS-aa8be4c3
JAVA_TOOL_OPTIONS = -Dfile.encoding=UTF-8
DEBUG_ENV_VAR = UnityHub
ProgramW6432 = C:\Program Files
FPS_BROWSER_APP_PROFILE_STRING = Internet Explorer
TEMP = C:\Users\PolyMad\AppData\Local\Temp
Path = C:\Program Files\Oculus\Support\oculus-runtime;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Common Files\Autodesk Shared\;C:\Program Files (x86)\Common Files\Acronis\SnapAPI\;C:\Program Files (x86)\Common Files\Acronis\VirtualFile\;C:\Program Files (x86)\Common Files\Acronis\VirtualFile64\;C:\Program Files (x86)\Common Files\Acronis\FileProtector\;C:\Program Files (x86)\Common Files\Acronis\FileProtector64\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\Prio;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Users\PolyMad\AppData\Local\Microsoft\WindowsApps;C:\Users\PolyMad\.dotnet\tools
USERNAME = PolyMad
COMPUTERNAME = POLYMAD-PC
USERDOMAIN_ROAMINGPROFILE = POLYMAD-PC
PATHEXT = .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
SystemDrive = C:
ALLUSERSPROFILE = C:\ProgramData
SENTRY_ACCESS_TOKEN = 3df78d9e53f8456aa90fbae044ce1a6261421ab1d0014674bc2e933477289017
HEAP_CLIENT_TOKEN_STAGING = 3786794399
FPS_BROWSER_USER_PROFILE_STRING = Default
windir = C:\WINDOWS
AMPLITUDE_API_KEY_STAGING = 83ee04fccc67e4fcc7dd527c4c6f1e21
CommonProgramFiles(x86) = C:\Program Files (x86)\Common Files
APPDATA = C:\Users\PolyMad\AppData\Roaming
CommonProgramFiles = C:\Program Files\Common Files
PROCESSOR_LEVEL = 6
CommonProgramW6432 = C:\Program Files\Common Files
ProgramFiles(x86) = C:\Program Files (x86)
SESSIONNAME = Console
LOGONSERVER = \\POLYMAD-PC
LOCALAPPDATA = C:\Users\PolyMad\AppData\Local
HOMEPATH = \Users\PolyMad
LAUNCH_DARKLY_CLIENT_TOKEN_STAGING = 60a7e30fafc7e60e33446282
HOMEDRIVE = C:
[COLOR=#ff0000][B]OneDrive = C:\Users\PolyMad\OneDrive[/B][/COLOR]
ProgramData = C:\ProgramData
ORIGINAL_XDG_CURRENT_DESKTOP = undefined


stderr[
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
M:\WORK\_SGR\SGR\Library\Bee\Android\Prj\Mono2x\Gradle\unityLibrary\src\main\java\com\unity\androidnotifications\UnityNotificationManager.java:164: error: cannot find symbol
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU)
                                                        ^
  symbol:   variable TIRAMISU
  location: class VERSION_CODES
M:\WORK\_SGR\SGR\Library\Bee\Android\Prj\Mono2x\Gradle\unityLibrary\src\main\java\com\unity\androidnotifications\UnityNotificationManager.java:165: error: cannot find symbol
            permissionGranted = mContext.checkCallingOrSelfPermission(Manifest.permission.POST_NOTIFICATIONS) == PackageManager.PERMISSION_GRANTED;
                                                                                         ^
  symbol:   variable POST_NOTIFICATIONS
  location: class permission
[B][COLOR=#ff0000]Note: M:\WORK\_SGR\SGR\Library\Bee\Android\Prj\Mono2x\Gradle\unityLibrary\src\main\java\com\unity3d\player\UnityPlayerActivity.java uses or overrides a deprecated API.[/COLOR][/B]
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors

FAILURE: Build failed with an exception.

* What went wrong:
[B][COLOR=#ff0000]Execution failed for task ':unityLibrary:compileReleaseJavaWithJavac'.[/COLOR][/B]
> Compilation failed; see the compiler error output for details.

* 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 2s
]
stdout[
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2022.3.7f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\build-tools\32.0.0\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2022.3.7f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2022.3.7f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-31\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2022.3.7f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-32\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2022.3.7f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\tools\package.xml. Probably the SDK is read-only
> Task :unityLibrary:preBuild UP-TO-DATE
> Task :unityLibrary:preReleaseBuild UP-TO-DATE
> Task :unityLibrary:compileReleaseAidl NO-SOURCE
> Task :launcher:preBuild UP-TO-DATE
> Task :unityLibrary:mergeReleaseJniLibFolders UP-TO-DATE
> Task :launcher:preReleaseBuild UP-TO-DATE
> Task :launcher:compileReleaseAidl NO-SOURCE
> Task :launcher:generateReleaseBuildConfig UP-TO-DATE
> Task :launcher:javaPreCompileRelease UP-TO-DATE
> Task :unityLibrary:mergeReleaseNativeLibs UP-TO-DATE
> Task :launcher:generateReleaseResValues UP-TO-DATE
> Task :unityLibrary:stripReleaseDebugSymbols UP-TO-DATE
> Task :launcher:createReleaseCompatibleScreenManifests UP-TO-DATE
> Task :launcher:extractDeepLinksRelease UP-TO-DATE
> Task :unityLibrary:copyReleaseJniLibsProjectAndLocalJars UP-TO-DATE
> Task :launcher:extractProguardFiles UP-TO-DATE
> Task :unityLibrary:compileReleaseRenderscript NO-SOURCE
> Task :unityLibrary:generateReleaseBuildConfig UP-TO-DATE
> Task :unityLibrary:generateReleaseResValues UP-TO-DATE
> Task :unityLibrary:generateReleaseResources UP-TO-DATE
> Task :unityLibrary:packageReleaseResources UP-TO-DATE
> Task :launcher:mergeReleaseJniLibFolders UP-TO-DATE
> Task :unityLibrary:parseReleaseLocalResources UP-TO-DATE
> Task :unityLibrary:processReleaseManifest UP-TO-DATE
> Task :launcher:checkReleaseDuplicateClasses UP-TO-DATE
> Task :launcher:desugarReleaseFileDependencies UP-TO-DATE
> Task :launcher:mergeExtDexRelease UP-TO-DATE
> Task :launcher:mergeReleaseShaders UP-TO-DATE
> Task :unityLibrary:generateReleaseRFile UP-TO-DATE
> Task :launcher:compileReleaseShaders NO-SOURCE
> Task :launcher:generateReleaseAssets UP-TO-DATE
> Task :launcher:processReleaseJavaRes NO-SOURCE
> Task :launcher:collectReleaseDependencies UP-TO-DATE
> Task :launcher:sdkReleaseDependencyData UP-TO-DATE
> Task :launcher:validateSigningRelease UP-TO-DATE
> Task :launcher:writeReleaseAppMetadata UP-TO-DATE
> Task :launcher:writeReleaseSigningConfigVersions UP-TO-DATE
> Task :unityLibrary:extractReleaseAnnotations UP-TO-DATE
> Task :unityLibrary:javaPreCompileRelease UP-TO-DATE

> Task :unityLibrary:compileReleaseJavaWithJavac FAILED
29 actionable tasks: 1 executed, 28 up-to-date
]
exit code: 1
UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <3692a30af1114a098ee2388137c8a827>:0)
UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <3692a30af1114a098ee2388137c8a827>:0)
UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <3692a30af1114a098ee2388137c8a827>:0)
UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action`1[T] progress, System.String error) (at <3692a30af1114a098ee2388137c8a827>:0)
UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, Unity.Android.Gradle.AndroidGradle androidGradle, System.String workingdir, System.String task, System.Action`1[T] progress) (at <3692a30af1114a098ee2388137c8a827>:0)
Rethrow as GradleInvokationException: Gradle build failed
UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, Unity.Android.Gradle.AndroidGradle androidGradle, System.String workingdir, System.String task, System.Action`1[T] progress) (at <3692a30af1114a098ee2388137c8a827>:0)
UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <3692a30af1114a098ee2388137c8a827>:0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <3692a30af1114a098ee2388137c8a827>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2022.3.7f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\build-tools\32.0.0\package.xml. [B][COLOR=#ff0000]Probably the SDK is read-only[/COLOR][/B]
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2022.3.7f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools\package.xml. [B][COLOR=#ff0000]Probably the SDK is read-only[/COLOR][/B]
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2022.3.7f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-31\package.xml. [B][COLOR=#ff0000]Probably the SDK is read-only[/COLOR][/B]
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2022.3.7f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-32\package.xml. [B][COLOR=#ff0000]Probably the SDK is read-only[/COLOR][/B]
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2022.3.7f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\tools\package.xml. [B][COLOR=#ff0000]Probably the SDK is read-only[/COLOR][/B]
> Task :launcher:preBuild UP-TO-DATE
> Task :launcher:preReleaseBuild UP-TO-DATE
> Task :unityLibrary:preBuild UP-TO-DATE
> Task :unityLibrary:preReleaseBuild UP-TO-DATE
> Task :launcher:generateReleaseBuildConfig UP-TO-DATE
> Task :unityLibrary:compileReleaseAidl NO-SOURCE
> Task :unityLibrary:mergeReleaseJniLibFolders UP-TO-DATE
> Task :launcher:javaPreCompileRelease UP-TO-DATE
> Task :launcher:compileReleaseAidl NO-SOURCE
> Task :launcher:generateReleaseResValues UP-TO-DATE
> Task :launcher:createReleaseCompatibleScreenManifests UP-TO-DATE
> Task :unityLibrary:mergeReleaseNativeLibs UP-TO-DATE
> Task :launcher:extractDeepLinksRelease UP-TO-DATE
> Task :launcher:extractProguardFiles UP-TO-DATE
> Task :launcher:mergeReleaseJniLibFolders UP-TO-DATE
> Task :unityLibrary:stripReleaseDebugSymbols UP-TO-DATE
> Task :unityLibrary:copyReleaseJniLibsProjectAndLocalJars UP-TO-DATE
> Task :unityLibrary:compileReleaseRenderscript NO-SOURCE
> Task :unityLibrary:generateReleaseBuildConfig UP-TO-DATE
> Task :unityLibrary:generateReleaseResValues UP-TO-DATE
> Task :unityLibrary:generateReleaseResources UP-TO-DATE
> Task :unityLibrary:packageReleaseResources UP-TO-DATE
> Task :unityLibrary:parseReleaseLocalResources UP-TO-DATE
> Task :launcher:checkReleaseDuplicateClasses UP-TO-DATE
> Task :unityLibrary:processReleaseManifest UP-TO-DATE
> Task :launcher:desugarReleaseFileDependencies UP-TO-DATE
> Task :launcher:mergeExtDexRelease UP-TO-DATE
> Task :launcher:mergeReleaseShaders UP-TO-DATE
> Task :launcher:compileReleaseShaders NO-SOURCE
> Task :launcher:generateReleaseAssets UP-TO-DATE
> Task :launcher:processReleaseJavaRes NO-SOURCE
> Task :unityLibrary:generateReleaseRFile UP-TO-DATE
> Task :launcher:collectReleaseDependencies UP-TO-DATE
> Task :launcher:sdkReleaseDependencyData UP-TO-DATE
> Task :launcher:validateSigningRelease UP-TO-DATE
> Task :launcher:writeReleaseAppMetadata UP-TO-DATE
> Task :launcher:writeReleaseSigningConfigVersions UP-TO-DATE
> Task :unityLibrary:extractReleaseAnnotations UP-TO-DATE
> Task :unityLibrary:javaPreCompileRelease UP-TO-DATE

> Task :unityLibrary:compileReleaseJavaWithJavac FAILED
29 actionable tasks: 1 executed, 28 up-to-date

UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

This is a brand new installation of Unity 2022.3.7f1.
Any idea what’s happening?
Why it’s tracking OCULUS?
Why it’s tracking ONEDRIVE, which I don’t use?
Why it’s tracking 3DS Max?
This is all stuff that shouldn’t happen, I touched nothing, and all the errors refer to Java inside Unity.

How to troubleshoot build failures:

First, make a blank project with a single blank scene and prove that it builds successfully.

If the blank project does NOT build, go fix your Unity installation or your other tools, such as Android SDK, NDK, JDK, etc. It may even be necessary to change to a different version of Unity3D. It is generally best to stay with LTS versions of Unity3D.

Until you can build a blank project to the target platform, don’t fiddle with anything else.

Once you can build a blank project, now bisect the problem by bringing over parts of your current project and building it one subsystem at a time, perhaps stubbing things out that might trigger compiler errors.

Most often things that prevent building are third-party libraries such as Firebase.

Once you identify the subsystem, go to the documentation for it and make sure you are doing it correctly.

It may also be helpful to work through a tutorial or two for whatever subsystem is making the build fail.

Android build not building:

Recently (circa July 2022) there have been reports of Unity’s installer failing to install the Android Tools.

Here was how I brought up Unity2020.3.41 and the Android SDK 31 on October 30, 2022:

Android Gradle errors and other related stuff:

Thank you very much, man.
But this is crazy.
I am in no way able to solve this, I’m no professional programmer and all these systems are out of my knowledge.
I didn’t install Firebase or anything that could mangle the core of Unity or anything else.
I installed Playmaker, TextMeshPro, and this version again poses the problem of finding the Sprite Editor, which looks completely missing, so I’m also stuck with the sprites.
This LTS version is really terrible…

This is very unfortunate but I tend to agree. I hope they get things back on track ASAP.

Tested with brand new template 3D mobile project: does not compile.

BTW: I don’t have ANY other tool installed. I only use the Unity installation. EXACTLY to try to avoid this type of problems, which I’m not able to solve.
And guess what happens? I get f anyway.

To solve this problem, you need Android SDK 33. A simple solution is to set your target SDK to 33 in player settings.
If you wish to use lower target sdk, then you’ll need a custom gradle template with compileSdk set to 33 (Unity sets it to the same as target sdk).

Thank you, man, but I don’t know exactly what you are talking about: I am using the SDK installed by Unity, I didn’t change ANYTHING in the preferences after installation of the latest LTS version.

Should I install another SDK to get v.33?
And then set Unity to use that?

Select 33 as target in Player Settings and Unity should automatically download and install it, if not present.
By the end of this month Google Play will require all new apps and updates to target 33.

9222723--1287696--upload_2023-8-15_1-30-15.png

Should I select it here?
Android 13?

Should I select on both Minimum API Level and Target API Level?

I think you’ve clicked on Minimum SDK. The Target SDK is below it. Yes, select 13 for target, minimum doesn’t matter.

Oh ok, thank you again.

Edit: btw this worked! I am so happy :smile: