It seems inevitable that you will run into either a Gradle or Java error when trying to build an AR or VR application.
The latest incantation 🪄 of this problem 🚨 for me is a missing Gradle installation in Unity 2021.3.6f1.
A version of Gradle is typically found in Unity’s Tools directory. The path to this Tools directory should be
/Applications/Unity/Hub/Editor/<Your Unity Version>/PlaybackEngines/AndroidPlayer/
but it isn’t there.
I had 2021.3.5f1 installed, so I copied /Applications/Unity/Hub/Editor/2021.3.5f1/PlaybackEngines/AndroidPlayer/Tools
over to
/Applications/Unity/Hub/Editor/2021.3.6f1/PlaybackEngines/AndroidPlayer/
and all seems good.
There’s more conversation about the issue over at this answers.unity.com thread.