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

上一篇:Android Studio报错:Failed to delete some children. This might happen because a process has files open


下一篇:5-vulnhub W1R3S 1