android studio在升級到Arctic Fox 2020.3.1版本后使用.gradlew命令報錯:
ERROR: JAVA_HOME is set to an invalid directory: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
大概意思是jdk的設置路徑是非法的;之前關於as的jdk路徑設置使用的內嵌jdk,在.bash_profile中的配置路徑:
/Applications/Android\ Studio.app/Contents/jre/jdk/Contents/Home
在進入android studio的包中確認具體文件路徑時發現實際路徑變成了這個,中間少了一個jdk
/Applications/Android\ Studio.app/Contents/jre/Contents/Home
同時在AS-file-Project Structure-SDK Location中查看jdk配置時發現可指定jdk路徑,默認的jdk下載路徑在下面的文件中
/Users/<userName>/Library/Java/JavaVirtualMachines/corretto-1.8.0_302/Contents/Home
測試發現兩者都可以解決問題。
具體步驟:
1.設置JAVA_HOME為內嵌或者java中的路徑
2.重啟as