MacOS versions before Big Sur: export JAVA_HOME=/Applications/Android\\ Studio.app/Contents/jre/jdk/Contents/Home/. Catalina, Big Sur, Mentere and above: export JAVA_HOME=/Applications/Android\\ Studio.app/Contents/jre/Contents/Home