I made a lot of different changes until I was finally able to
build for android again. I will list them below, following these I hope you can solve your problem as well.
0- Make sure to create a backup of your entire project, we'll be deleting a ton of stuff.
1- Inside your Project folder, delete the Library and Temp folders. Temp folder is only visible when the editor is running.
2- There seems to be something wrong with package resolution. the default one tries to run a bat file that does not exist. One way is to create or download it yourself but I did that with no luck. The progress was still stuck on 0% but this time with no errors. instead, Install unity jar resolver (Github: https://github.com/googlesamples/unity-jar-resolver) I installed it using GIT from package manager (https://github.com/googlesamples/unity-jar-resolver?tab=readme-ov-file#install-via-git-url)
3- I got hundreds of errors in my console after the previous step. what you want to do now is to delete the folder called "MobileDependencyResolver" from your Assets folder. You'll be shown a messagebox about re-importing it, click yes and let it process everything.
4- Now you'll have a new option in the Assets menu (top bar in unity editor) called External Dependency Manager. Assets > External Dependency Manager > Android Resolver > Force Resolve
Click force resolve once, then try to build for android again.
Notes:
in the process I also deleted .gradle and .android folders from my user folder (C:\Users\<username>) but I don't think it affected the outcome.
Other useful links:
https://discussions.unity.com/t/win32exception-at-resolving-android-dependencies-cannot-find-file-gradlew-bat/904380