赞
踩
下载 Android Studio 和应用工具 - Android 开发者 | Android Developers
然后根据提示安装即可
下载之后点击安装默认安装路径就可以,根据提示完成安装
如果不想注册可以直接通过该链接下载,资源一样: jdk-8u381-macosx-aarch64.dmg
安装之后路径一般都是 /Library/Java/JavaVirtualMachines/jdk-1.8.jdk/Contents/Home
在MacOS系统中,打开终端后,您将会看到一个命令行界面。
通过终端,通过命令vim ~/.bash_profile编辑文件,如果没有他会帮忙创建一个文件,配置全局的环境变量。
输入的环境变量配置
- export JAVA_HOME=~/Library/Java/JavaVirtualMachines/jdk-1.8.jdk/Contents/Home
- export PATH=$JAVA_HOME/bin:$PATH:.
- export CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:.
-
- export ANDROID_HOME=/Users/dongdong/Library/Android/sdk
- export PATH=$PATH:$ANDROID_HOME/tools
- export PATH=$PATH:$ANDROID_HOME/platform-tools
export JAVA_HOME=~/Library/Java/JavaVirtualMachines/jdk-1.8.jdk/Contents/Home
其中的~如果是在用户名下的Library就需要加一下,如果不是就不需要加
然后保存关闭,在命令中使用source ~/.bash_profile 使得刚刚配置的立即生效。
最后一步是验证Java环境变量是否成功配置。在终端中输入以下命令:
java -version
如果成功配置了Java环境变量,您将会看到Java的版本信息。
Multiple Gradle daemons might be spawned because the Gradle JDK and JAVA_HOME locations are different. Project 'Android02' is using the following JDK location when running Gradle: '/Library/Java/JavaVirtualMachines/jdk-1.8.jdk/Contents/Home' The system environment variable JAVA_HOME is: '/Applications/Android Studio.app/Contents/jbr/Contents/Home' If you dont need to use different paths (or if JAVA_HOME is undefined), you can avoid spawning multiple daemons by setting JAVA_HOME and the JDK location to the same path. More info... Select the Gradle JDK location Do not show this warning again
- Multiple Gradle daemons might be spawned because the Gradle JDK and JAVA_HOME
- locations are different. Project 'Android02' is using the following JDK location
- when running Gradle: '/Library/Java/JavaVirtualMachines/jdk-1.8.jdk/Contents/Home'
- The system environment variable JAVA_HOME is: '/Applications/Android
- Studio.app/Contents/jbr/Contents/Home' If you dont need to use different paths (or
- if JAVA_HOME is undefined), you can avoid spawning multiple daemons by setting
- JAVA_HOME and the JDK location to the same path. More info... Select the Gradle JDK
- location Do not show this warning again
查询之后发现是因为从 macOS 10.15+, zsh 成为默认的 Terminal shell,所以我们需要在.zshdk中编写如下命令:
先通过命令
vim ~/.zshrc
创建并编辑.zshrc文件,在该文件中添加如下命令
source ~/.bash_profile
然后通过
source ~/.zshrc
使得该文件立即生效
这个是通过Invalidate Caches 重新启动AndroidStudio,然后重新设置Gradle JDK的目录就可以了
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。