下载安装完成后,在终端中打开此文件.bash_profile
// 如果没有先执行touch
touch .bash_profile
// 如果有直接执行open
open .bash_profile
# flutter 配置路径
export PUB_HOSTED_URL=https://pub.flutter-io.cn #//国内用户需要设置
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn #//国内用户需要设置
export PATH=/Users/headway/development/flutter/bin:$PATH
#配置android
export ANDROID_HOME="/Users/headway/Library/Android/sdk" #//android sdk目录,替换为你自己的即可
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/platform-tools
# 配置java
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_251.jdk/Contents/Home
PATH=$JAVA_HOME/bin:$PATH:.
CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:.
export JAVA_HOME
export PATH
export CLASSPATH
#配置gradle
GRADLE_HOME=/Users/headway/gradle/gradle-6.6.1
export GRADLE_HOME
export PATH=$PATH:$GRADLE_HOME/bin
配置完成之后
在终端执行(不执行,关闭重新打开也可)
source .bash_profile
然后执行
java -version
gradle -version
xxxxxxxxx ~ % java -version
java version "1.8.0_251"
Java(TM) SE Runtime Environment (build 1.8.0_251-b08)
Java HotSpot(TM) 64-Bit Server VM (build 25.251-b08, mixed mode)
xxxxxxxxxx~ % gradle -version
------------------------------------------------------------
Gradle 6.6.1
------------------------------------------------------------
Build time: 2020-08-25 16:29:12 UTC
Revision: f2d1fb54a951d8b11d25748e4711bec8d128d7e3
Kotlin: 1.3.72
Groovy: 2.5.12
Ant: Apache Ant(TM) version 1.10.8 compiled on May 10 2020
JVM: 1.8.0_251 (Oracle Corporation 25.251-b08)
OS: Mac OS X 10.16 x86_64
显示版本即安装完成