JAVA_HOME is set to an invalid directory


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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM