Getting gradle errors while building apk

Getting below errors

FAILURE: Build failed with an exception.

  • Where:
    Build file ‘C:\Users\alhat\OneDrive\Documents\GitHub\Medals\Library\Bee\Android\Prj\Mono2x\Gradle\build.gradle’ line: 14

  • What went wrong:
    Could not compile build file ‘C:\Users\alhat\OneDrive\Documents\GitHub\Medals\Library\Bee\Android\Prj\Mono2x\Gradle\build.gradle’.

startup failed:
build file ‘C:\Users\alhat\OneDrive\Documents\GitHub\Medals\Library\Bee\Android\Prj\Mono2x\Gradle\build.gradle’: 14: all buildscript {} blocks must appear before any plugins {} blocks in the script

See Using Gradle Plugins for information on the plugins {} block

@ line 14, column 1.
buildscript {
^

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.

BUILD FAILED in 964ms

0x00007ff60535b59d (Unity) StackWalker::GetCurrentCallstack
0x00007ff605360649 (Unity) StackWalker::ShowCallstack
0x00007ff60634ff91 (Unity) GetStacktrace
0x00007ff606a0a17e (Unity) DebugStringToFile
0x00007ff60424a7f8 (Unity) DebugLogHandler_CUSTOM_Internal_Log
0x000002954da38a53 (Mono JIT Code) (wrapper managed-to-native) UnityEngine.DebugLogHandler:Internal_Log (UnityEngine.LogType,UnityEngine.LogOption,string,UnityEngine.Object)
0x000002954da3896b (Mono JIT Code) UnityEngine.DebugLogHandler:LogFormat (UnityEngine.LogType,UnityEngine.Object,string,object)
0x000002954da386b0 (Mono JIT Code) UnityEngine.Logger:Log (UnityEngine.LogType,object)
0x000002954da38575 (Mono JIT Code) UnityEngine.Debug:LogError (object)
0x000002954da38283 (Mono JIT Code) UnityEditor.Android.GradleInvokationException:ParseAndShowException ()
0x0000029475f616c3 (Mono JIT Code) UnityEditor.Android.PostProcessor.PostProcessRunner:RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext)
0x000002954da03873 (Mono JIT Code) UnityEditor.Android.PostProcessAndroidPlayer:PostProcess (UnityEditor.Modules.BuildPostProcessArgs,AndroidPlayerBuildProgram.Data.AndroidPlayerBuildProgramOutput)
0x00000295449e0db3 (Mono JIT Code) UnityEditor.Android.AndroidBuildPostprocessor:PostProcess (UnityEditor.Modules.BuildPostProcessArgs,UnityEditor.BuildProperties&)
0x00000295449e0481 (Mono JIT Code) UnityEditor.PostprocessBuildPlayer:Postprocess (UnityEditor.BuildTargetGroup,UnityEditor.BuildTarget,int,string,string,string,int,int,UnityEditor.BuildOptions,UnityEditor.RuntimeClassRegistry,UnityEditor.Build.Reporting.BuildReport)
0x00000295449e07f5 (Mono JIT Code) (wrapper runtime-invoke) :runtime_invoke_void_int_int_int_object_object_object_int_int_int_object_object (object,intptr,intptr,intptr)
0x00007ffc3b324c2e (mono-2.0-bdwgc) mono_jit_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/mini/mini-runtime.c:3445)
0x00007ffc3b25d254 (mono-2.0-bdwgc) do_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/metadata/object.c:3068)
0x00007ffc3b25d3cc (mono-2.0-bdwgc) mono_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/metadata/object.c:3115)
0x00007ff6052743b4 (Unity) scripting_method_invoke
0x00007ff605251fc4 (Unity) ScriptingInvocation::Invoke
0x00007ff606d7ddd1 (Unity) CallMono
0x00007ff606d8737d (Unity) PostprocessPlayer
0x00007ff606d81c13 (Unity) DoBuildPlayer_PostBuild
0x00007ff606d7fd2e (Unity) DoBuildPlayer
0x00007ff606d731c8 (Unity) BuildPlayer
0x00007ff604ade85f (Unity) BuildPipeline::BuildPlayerInternalNoCheck
0x00007ff60487d7ec (Unity) BuildPipeline_CUSTOM_BuildPlayerInternalNoCheck
0x0000029448df1f87 (Mono JIT Code) (wrapper managed-to-native) UnityEditor.BuildPipeline:BuildPlayerInternalNoCheck (string,string,string,UnityEditor.BuildTargetGroup,UnityEditor.BuildTarget,int,UnityEditor.BuildOptions,string,bool)
0x0000029448df1803 (Mono JIT Code) UnityEditor.BuildPlayerWindow/DefaultBuildMethods:BuildPlayer (UnityEditor.BuildPlayerOptions)
0x00000293aff0dd0b (Mono JIT Code) UnityEditor.BuildPlayerWindow:CallBuildMethods (bool,UnityEditor.BuildOptions)
0x00000293aff0d82b (Mono JIT Code) UnityEditor.BuildPlayerWindow/<>c__DisplayClass46_0:b__0 ()
0x00000293aff0d7d9 (Mono JIT Code) UnityEditor.GenericMenu:CatchMenu (object,string,int)
0x00000293aff0d66e (Mono JIT Code) (wrapper runtime-invoke) :runtime_invoke_void__this___object_object_int (object,intptr,intptr,intptr)
0x00007ffc3b324c2e (mono-2.0-bdwgc) mono_jit_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/mini/mini-runtime.c:3445)
0x00007ffc3b25d254 (mono-2.0-bdwgc) do_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/metadata/object.c:3068)
0x00007ffc3b25d3cc (mono-2.0-bdwgc) mono_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/metadata/object.c:3115)
0x00007ff6052743b4 (Unity) scripting_method_invoke
0x00007ff605251fc4 (Unity) ScriptingInvocation::Invoke
0x00007ff605d654db (Unity) CustomPopupMenuInterface::Execute
0x00007ff605ce8442 (Unity) MenuController::ExecuteMenuItem
0x00007ff60636ff9e (Unity) ShowDelayedContextMenu
0x00007ff6063813ce (Unity) GUIView::OnInputEvent
0x00007ff605da5fc3 (Unity) GUIView::ProcessInputEventFromAPI
0x00007ff605da5e98 (Unity) GUIView::ProcessInputEvent
0x00007ff60637a6cc (Unity) GUIView::DoPaint
0x00007ff6063833fc (Unity) GUIView::RepaintViews
0x00007ff605ec770e (Unity) PlayerLoopController::InternalUpdateScene
0x00007ff605ed425d (Unity) PlayerLoopController::UpdateSceneIfNeededFromMainLoop
0x00007ff605ed2541 (Unity) Application::TickTimer
0x00007ff606355c2a (Unity) MainMessageLoop
0x00007ff60635ade0 (Unity) WinMain
0x00007ff60771b73e (Unity) __scrt_common_main_seh
0x00007ffd0d6e257d (KERNEL32) BaseThreadInitThunk
0x00007ffd0eb0af28 (ntdll) RtlUserThreadStart

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

Environment Variables:
SHIM_MCCOMPAT = 0x810000001
PROCESSOR_ARCHITECTURE = AMD64
TEMP = C:\Users\alhat\AppData\Local\Temp
AMPLITUDE_API_KEY_YELLOWBUCKET_DEV = 48835b4d1f5e342aefe5f016324d296a
ANDROID_NDK_ROOT = C:\Program Files\Unity\Hub\Editor\2022.3.40f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK
DriverData = C:\Windows\System32\Drivers\DriverData
USERDOMAIN = VSATAV
CommonProgramFiles(x86) = C:\Program Files (x86)\Common Files
COMPUTERNAME = VSATAV
DEBUG_ENV_VAR = UnityHub
LOGONSERVER = \VSATAV
AMPLITUDE_TOKEN_GREENBUCKET_PROD = ZpUcbAdZXJYzNSoHsAWtL_s_JppwWid9
PUBLIC = C:\Users\Public
ProgramData = C:\ProgramData
SESSIONNAME = Console
AMPLITUDE_TOKEN_YELLOWBUCKET_PROD = UYDQtPOw83dIfVy3SrW5oMyo7ru4PRkV
NVIDIAWHITELISTED = 0x01
SCE_SCREAM_TOOL = C:\Program Files (x86)\SCE\Prospero\Tools\Scream Tool\screamtool_siei
APPDATA = C:\Users\alhat\AppData\Roaming
SystemRoot = C:\WINDOWS
windir = C:\WINDOWS
AMPLITUDE_API_KEY_REDBUCKET_DEV = 46b8b46515e7632fc42a504b72e05fd0
ProgramFiles(x86) = C:\Program Files (x86)
ProgramW6432 = C:\Program Files
USERNAME = alhat
SCE_PROSPERO_FSD = P:
OS = Windows_NT
PROCESSOR_IDENTIFIER = Intel64 Family 6 Model 140 Stepping 2, GenuineIntel
GRDKLatest = C:\Program Files (x86)\Microsoft GDK\240301\GRDK
HOMEPATH = \Users\alhat
FPS_BROWSER_USER_PROFILE_STRING = Default
AMPLITUDE_TOKEN_REDBUCKET_DEV = U4PSN7S7PuYVRODivvdcFwbu8R6IHGqa
CHROME_CRASHPAD_PIPE_NAME = \.\pipe\crashpad_4480_CCUOBYBZYZHNLVBV
PROCESSOR_LEVEL = 6
CommonProgramFiles = C:\Program Files\Common Files
ZES_ENABLE_SYSMAN = 1
SCE_ENABLE_HOST_TOOLS_TELEMETRY = 1
GameDKLatest = C:\Program Files (x86)\Microsoft GDK\240301
SCE_PROSPERO_SDK_DIR = C:\Program Files (x86)\SCE\Prospero SDKs\6.000
USERDOMAIN_ROAMINGPROFILE = VSATAV
JAVA_HOME = C:\Program Files\Unity\Hub\Editor\2022.3.40f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK
EFC_10504 = 1
CommonProgramW6432 = C:\Program Files\Common Files
AMPLITUDE_TOKEN_YELLOWBUCKET_DEV = wKi8foVigDditGFvmZewRFWsEbX9Y0YO
AMPLITUDE_API_KEY_GREENBUCKET_DEV = 3ded2a762163603391a425f688f990c8
AMPLITUDE_API_KEY_REDBUCKET_PROD = ca12bb461ea96f9bdf5df4ded7d52994
HOMEDRIVE = C:
AMPLITUDE_API_KEY_STAGING = 83ee04fccc67e4fcc7dd527c4c6f1e21
GXDKLatest = C:\Program Files (x86)\Microsoft GDK\240301\GXDK
OneDrive = C:\Users\alhat\OneDrive
AMPLITUDE_API_KEY_YELLOWBUCKET_PROD = e03a9bbe92dc38a88cdb068d24c65b46
IGCCSVC_DB = AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAA2RZl77MXLUm06KNdDNZovgQAAAACAAAAAAAQZgAAAAEAACAAAACNkUZ1XWfYCog0StJNEqPkWnt19xl3a84bl1WAiWxargAAAAAOgAAAAAIAACAAAADCEHxsUPrL28zoKnVp1EKf4ej+PKMOERI/B2r3DlF7TmAAAAASM2NEvK0mn/Q9C0XSYb0p2TPQcUF2LoyIEbnTs4apEdPtK24he+kth4dDENz9ScJp6FwtHX6/lcJJ49CQeKeRzQdguNLvgSpd1DE2U6NZM7PYW/eInDztqO4wTr6Ybr1AAAAAQFMzWbpxZfLWdCJ1HmjevM8fpAD+GIwEXl0YnbUvx+Q9yNAu+rc4+EqyIiyoxzVpuFfuVVMTc05u3BPvCwVFYQ==
PATHEXT = .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
GameDK = C:\Program Files (x86)\Microsoft GDK
AMPLITUDE_TOKEN_REDBUCKET_PROD = jTIgKs5KTZOjiqEEVdZFbgo_VRhABduL
SCE_ROOT_DIR = C:\Program Files (x86)\SCE
NUMBER_OF_PROCESSORS = 8
AMPLITUDE_TOKEN_GREENBUCKET_DEV = 84H2gMm_FJzhr3mBaX1lM1JVukmCM7d9
SCE_PROSPERO_SAMPLE_DIR = C:\Program Files (x86)\SCE\Prospero SDKs\6.000\target\samples
AMPLITUDE_DEPLOYMENT_KEY_RED_BUCKET_DEV = client-wbjHYrmeSR87GmWOE7LDpf7sUySOIKHm
PSModulePath = C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
AMPLITUDE_API_KEY_GREENBUCKET_PROD = c86fea37a9e1d3f0878b96e15b111c7c
ComSpec = C:\WINDOWS\system32\cmd.exe
ORIGINAL_XDG_CURRENT_DESKTOP = undefined
PROCESSOR_REVISION = 8c02
AMPLITUDE_DEPLOYMENT_KEY_RED_BUCKET_PROD = client-zH8Y7OK1i331EKuG77C6UxN8ygcM6LzS
TMP = C:\Users\alhat\AppData\Local\Temp
SystemDrive = C:
AMPLITUDE_API_KEY = 28f3cae0b33b8b3702120c9ed1a935aa
FPS_BROWSER_APP_PROFILE_STRING = Internet Explorer
SENTRY_ACCESS_TOKEN = 3df78d9e53f8456aa90fbae044ce1a6261421ab1d0014674bc2e933477289017
ALLUSERSPROFILE = C:\ProgramData
Path = C:\Program Files (x86)\SCE\Prospero SDKs\6.000\host_tools\bin;C:\Program Files (x86)\SCE\Common\SceVSI-VS16\bin;C:\Program Files (x86)\SCE\Prospero\Tools\Publishing Tools\bin;C:\Program Files (x86)\SCE\Prospero\Tools\Target Manager Server\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files (x86)\SCE\Prospero\Tools\PS4 Razor GPU for Prospero\bin\CommandTools\bin;C:\Program Files (x86)\SCE\Prospero\Tools\Razor GPU\bin\CommandTools\bin;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit;C:\Program Files\dotnet;C:\Users\alhat\anaconda3;C:\Users\alhat\anaconda3\Library\mingw-w64\bin;C:\Users\alhat\anaconda3\Library\usr\bin;C:\Users\alhat\anaconda3\Library\bin;C:\Users\alhat\anaconda3\Scripts;C:\Users\alhat\AppData\Local\Microsoft\WindowsApps;C:\Users\alhat\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\alhat.dotnet\tools;C:\Users\alhat\AppData\Local\GitHubDesktop\bin
ProgramFiles = C:\Program Files
LOCALAPPDATA = C:\Users\alhat\AppData\Local
USERPROFILE = C:\Users\alhat
WOOTRIC_CLIENT_TOKEN = NPS-aa8be4c3

stderr[

FAILURE: Build failed with an exception.

  • Where:
    Build file ‘C:\Users\alhat\OneDrive\Documents\GitHub\Medals\Library\Bee\Android\Prj\Mono2x\Gradle\build.gradle’ line: 14

  • What went wrong:
    Could not compile build file ‘C:\Users\alhat\OneDrive\Documents\GitHub\Medals\Library\Bee\Android\Prj\Mono2x\Gradle\build.gradle’.

startup failed:
build file ‘C:\Users\alhat\OneDrive\Documents\GitHub\Medals\Library\Bee\Android\Prj\Mono2x\Gradle\build.gradle’: 14: all buildscript {} blocks must appear before any plugins {} blocks in the script

See Using Gradle Plugins for information on the plugins {} block

@ line 14, column 1.
buildscript {
^

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.

BUILD FAILED in 964ms
]
stdout[

]
exit code: 1
UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <312d82ffa0f7401da41d96df23cd3bb8>:0)
UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <312d82ffa0f7401da41d96df23cd3bb8>:0)
UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <312d82ffa0f7401da41d96df23cd3bb8>:0)
UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action1[T] progress, System.String error) (at <312d82ffa0f7401da41d96df23cd3bb8>: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 <312d82ffa0f7401da41d96df23cd3bb8>: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 <312d82ffa0f7401da41d96df23cd3bb8>:0)
UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <312d82ffa0f7401da41d96df23cd3bb8>:0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <312d82ffa0f7401da41d96df23cd3bb8>:0)
UnityEditor.GenericMenu:CatchMenu(Object, String, Int32)

Tried everything. upgraded unity, jdk ndk,sdk,android studio, reimported, changed that build gradle that was blocking but somehow it again goes down. trying to fix this from past 4 hours. please help me

I even format my PC. stil same. why unity why you do this?

resolved this issue by shifting the project to Unity 6000. (shifting alone did not work I had to create a new project and move everything there.)
Seems like Android wants us to use the latest stuff. Unity 2022.3 wants us to use the recommended version which is old now.