Publish for Androi 12 / API Level 31 from Unity 2019.4

I have followed the steps to build to Android 11 here successfully…

Unfortunately Play store now requires targeting 12, not 11, so I followed these instructions…

I get these 2 errors… if anyone can help, it would be hugely appreciated.
Using 2019.4.34f1
Gradle 6.1.1

A problem occurred evaluating project ‘:unityLibrary’.

Could not initialize class org.jetbrains.kotlin.gradle.plugin.sources.DefaultKotlinSourceSetKt

A problem occurred configuring project ‘:unityLibrary’.

compileSdkVersion is not specified. Please add it to build.gradle

Full error print out is here…

CommandInvokationFailure: Gradle build failed.
C:/Program Files/Unity/Hub/Editor/2019.4.34f1/Editor/Data/PlaybackEngines/AndroidPlayer\OpenJDK\bin\java.exe -classpath “C:\Users\kingm\Moge Files\ARQ\BUILDS\gradle-6.1.1\lib\gradle-launcher-6.1.1.jar” org.gradle.launcher.GradleMain “-Dorg.gradle.jvmargs=-Xmx4096m” “assembleRelease”
stderr[
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.

  • Where:
    Build file ‘C:\Users\kingm\Moge Files\ARQ\BUILDS\ARQueue_v2022\Temp\gradleOut\unityLibrary\build.gradle’ line: 38
  • What went wrong:
    A problem occurred evaluating project ‘:unityLibrary’.

Could not initialize class org.jetbrains.kotlin.gradle.plugin.sources.DefaultKotlinSourceSetKt

  • 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.
    ==============================================================================
    2: Task failed with an exception.

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

compileSdkVersion is not specified. Please add it to build.gradle

  • 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: DSL element ‘useProguard’ is obsolete.
It will be removed in version 5.0 of the Android Gradle plugin.
Use ‘android.enableR8’ in gradle.properties to switch between R8 and Proguard.
WARNING: DSL element ‘useProguard’ is obsolete.
It will be removed in version 5.0 of the Android Gradle plugin.
Use ‘android.enableR8’ in gradle.properties to switch between R8 and Proguard.
]
exit code: 1
UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at :0)
UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at :0)
UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at :0)
UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action1[T] progress, System.String error) (at <a62274e3cf264793ab003fc3e81fb523>:0) UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action1[T] progress) (at :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 :0)
UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at :0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at :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 :0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at :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 :0)
UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at :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 <785fa035f6c842aea795e821898770c6>:0)
UnityEditor.EditorApplication:Internal_CallGlobalEventHandler()

I’m not sure what is causing this issue, but note that Unity 2019.4 has reached end of life and is no longer supported. At time of writing, the oldest supported Unity LTS version is 2020.3.