- 打开终端、依次输入如下命令
cd ~
touch .bash_profile
open -e .bash_profile
进入根目录
创建 .bash_profile
打开 .bash_profile
提示没有权限要先设置读与写权限
- open -e .bash_profile 会打开文档输入一下内容
export ANDROID_HOME=/Users/XXX/Library/Android/sdk
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/platform-tools
XXX是自己电脑用户名
- 保存退出文档、执行source命令、关闭终端并退出
source .bash_profile
4.如果提示 command not found 执行以下命令
cd ~
source .bash_profile
6.如果macOS 在终端中使用 adb命令,每次都要source ~/.bash_profile 才生效
macOS下已经配置好Android开发环境,环境变量也添加了,但是在终端中使用adb命令每次都需要source .bash_profile之后才能识别,
否则就提示 zsh: command not found: adb
解决方案:
1、查看根目录下是否有.zshrc文件,如果没有就新建一个 touch .zshrc
2、打开这个文件 open -e .zshrc
3、在后面添加
# Enable my profile
source ~/.bash_profile
4、保存
5、输入source .bash_profile,是配置生效
然后就可以直接打开终端就使用adb命令了