- 打開終端、依次輸入如下命令
cd ~
touch .bash_profile
open -e .bash_profile
進入根目錄
創(chuàng)建 .bash_profile
打開 .bash_profile
提示沒有權(quán)限要先設(shè)置讀與寫權(quán)限
- open -e .bash_profile 會打開文檔輸入一下內(nèi)容
export ANDROID_HOME=/Users/XXX/Library/Android/sdk
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/platform-tools
XXX是自己電腦用戶名
- 保存退出文檔、執(zhí)行source命令、關(guān)閉終端并退出
source .bash_profile
4.如果提示 command not found 執(zhí)行以下命令
cd ~
source .bash_profile
6.如果macOS 在終端中使用 adb命令,每次都要source ~/.bash_profile 才生效
macOS下已經(jīng)配置好Android開發(fā)環(huán)境,環(huán)境變量也添加了,但是在終端中使用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命令了