Why I have problems with Unity with CommandInvokationFailure: Gradle build failed.?

I have an issue in Unity:

CommandInvokationFailure: Gradle build failed.
C:\Program Files\Unity\Hub\Editor\2022.2.5f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath “C:\Program Files\Unity\Hub\Editor\2022.2.5f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-7.2.jar” org.gradle.launcher.GradleMain “-Dorg.gradle.jvmargs=-Xmx4096m” “assembleDebug”

Environment Variables:
USERDOMAIN = USER-PC
ProgramFiles = C:\Program Files
TMP = C:\Users\User\AppData\Local\Temp
PROCESSOR_ARCHITECTURE = AMD64
NVCUDASAMPLES_ROOT = C:\ProgramData\NVIDIA Corporation\CUDA Samples\v10.1
PROCESSOR_REVISION = a502
OneDriveConsumer = C:\Users\User\OneDrive
OS = Windows_NT
CHROME_CRASHPAD_PIPE_NAME = \.\pipe\crashpad_33316_TVDEGMDKNBIFRCQJ
PROCESSOR_IDENTIFIER = Intel64 Family 6 Model 165 Stepping 2, GenuineIntel
CUDA_PATH = C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1
ProgramW6432 = C:\Program Files
CUDA_PATH_V10_1 = C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1
USERPROFILE = C:\Users\User
JAVA_HOME = C:\Program Files\Unity\Hub\Editor\2022.2.5f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK
CommonProgramFiles = C:\Program Files\Common Files
DriverData = C:\Windows\System32\Drivers\DriverData
ComSpec = C:\Windows\system32\cmd.exe
PSModulePath = C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules
ANDROID_NDK_ROOT = C:\Program Files\Unity\Hub\Editor\2022.2.5f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK
SystemRoot = C:\Windows
NUMBER_OF_PROCESSORS = 12
JAVA_TOOL_OPTIONS = -Dfile.encoding=UTF-8
NVCUDASAMPLES10_1_ROOT = C:\ProgramData\NVIDIA Corporation\CUDA Samples\v10.1
BURST_ANDROID_MIN_API_LEVEL = 22
VS140COMNTOOLS = C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools
HOMEDRIVE = C:
TEMP = C:\Users\User\AppData\Local\Temp
Path = C:\Program Files\Microsoft\jdk-11.0.12.7-hotspot\bin;C:\Program Files\Microsoft\jdk-11.0.16.101-hotspot\bin;C:\Program Files\Eclipse Foundation\jdk-8.0.302.8-hotspot\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\libnvvp;C:\Program Files\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Common Files\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\Microsoft SQL Server\130\Tools\Binn;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\Nsight Compute 2019.4.0;C:\Program Files\OpenSSL-Win64\bin;C:\Program Files\Microsoft SQL Server\150\Tools\Binn;C:\Program Files\dotnet;C:\Program Files (x86)\IncrediBuild;C:\Program Files\Git\cmd;C:\Users\User\AppData\Roaming\ActiveState\bin;C:\Users\User\AppData\Local\activestate\bin;C:\Users\User\AppData\Local\Programs\Python\Python310\Scripts;C:\Users\User\AppData\Local\Programs\Python\Python310;C:\Users\User\AppData\Local\Microsoft\WindowsApps;C:\Users\User.dotnet\tools;C:\Users\User.dotnet\tools
USERNAME = User
COMPUTERNAME = USER-PC
PATHEXT = .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
ALLUSERSPROFILE = C:\ProgramData
NVTOOLSEXT_PATH = C:\Program Files\NVIDIA Corporation\NvToolsExt
SystemDrive = C:
windir = C:\Windows
HOMEPATH = \Users\User
PUBLIC = C:\Users\Public
CommonProgramFiles(x86) = C:\Program Files (x86)\Common Files
APPDATA = C:\Users\User\AppData\Roaming
OneDrive = C:\Users\User\OneDrive
PROCESSOR_LEVEL = 6
CommonProgramW6432 = C:\Program Files\Common Files
ProgramFiles(x86) = C:\Program Files (x86)
NVIDIAWHITELISTED = 0x01
SESSIONNAME = Console
LOGONSERVER = \USER-PC
LOCALAPPDATA = C:\Users\User\AppData\Local
SHIM_MCCOMPAT = 0x810000001
USERDOMAIN_ROAMINGPROFILE = USER-PC
ProgramData = C:\ProgramData
ORIGINAL_XDG_CURRENT_DESKTOP = undefined

stderr[
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8

FAILURE: Build failed with an exception.

  • What went wrong:
    A problem occurred configuring project ‘:launcher’.

Could not resolve all artifacts for configuration ‘:launcher:classpath’.
Could not find com.android.tools.build:gradle:6.1.1.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/6.1.1/gradle-6.1.1.pom
- https://jcenter.bintray.com/com/android/tools/build/gradle/6.1.1/gradle-6.1.1.pom
Required by:
project :launcher

  • 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[

Configure project :
Build was configured to prefer settings repositories over project repositories but repository ‘Google’ was added by build file ‘build.gradle’
Build was configured to prefer settings repositories over project repositories but repository ‘BintrayJCenter’ was added by build file ‘build.gradle’
Build was configured to prefer settings repositories over project repositories but repository ‘flatDir’ was added by build file ‘build.gradle’

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use ‘–warning-mode all’ to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See Command-Line Interface
]
exit code: 1
exit code: 1
UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <84df4a4b958149188d1133032ffc50e9>:0)
UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <84df4a4b958149188d1133032ffc50e9>:0)
UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <84df4a4b958149188d1133032ffc50e9>:0)
UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action1[T] progress, System.String error) (at <84df4a4b958149188d1133032ffc50e9>:0) UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, Unity.Android.Gradle.AndroidGradle androidGradle, System.String workingdir, System.String task, System.Action1[T] progress) (at <84df4a4b958149188d1133032ffc50e9>: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 <84df4a4b958149188d1133032ffc50e9>:0)
UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <84df4a4b958149188d1133032ffc50e9>:0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <84df4a4b958149188d1133032ffc50e9>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

Another error:

Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8

FAILURE: Build failed with an exception.

  • What went wrong:
    A problem occurred configuring project ‘:launcher’.

Could not resolve all artifacts for configuration ‘:launcher:classpath’.
Could not find com.android.tools.build:gradle:6.1.1.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/6.1.1/gradle-6.1.1.pom
- https://jcenter.bintray.com/com/android/tools/build/gradle/6.1.1/gradle-6.1.1.pom
Required by:
project :launcher

  • 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&)

There is no such thing as Android Gradle plugin 6.1.1 it seems.
It jumped from 4.2.2 to 7.0.0.