no java runtime present requesting install

I used Unity Hub to install Android build tools. I can locate these files on my computer. I set JAVA_HOME and “java -version” command works fine.
When I try to build I get following error:
No Java runtime present, requesting install.
what can I do?
Unity Version: 2019.4.9f1.
Mac OS Catalina

did you figure this out?

Not sure if it will help, but I have seen a bug in Unity where Java is unrecognised.

  1. Go to Edit > Preferences > External Tools

  2. Where it says “JDK installed with Unity” untick it and re-tick it.

  3. Retry the build.

I know its weird, but its worked for me before.