You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Mac电脑adb: command not found问题求助——Android_Home配置异常

Fixing "-bash: adb: command not found" After Setting ANDROID_HOME on Mac

Hey there! Let's troubleshoot why your adb command isn't working after configuring ANDROID_HOME on your Mac. I'll walk you through common fixes step by step:

1. Ensure your shell is using the right configuration file

Mac's default terminal shell switched to zsh a while back, so if you're using the default setup, editing ~/.bash_profile might not apply to your active shell. Let's confirm:

  • Run this command to check your current shell:
    echo $SHELL
    
  • If the output is /bin/zsh, you have two options:
    • Move your Android configuration into ~/.zshrc instead of ~/.bash_profile, or
    • Add this line to ~/.zshrc to load your bash profile automatically:
      source ~/.bash_profile
      

2. Verify your ANDROID_HOME and PATH setup is complete

adb is located in the platform-tools folder of your Android SDK, so your config must include this path. Double-check your profile file (either ~/.bash_profile or ~/.zshrc) has these lines (replace the SDK path with your actual path from your screenshot):

export ANDROID_HOME=/Users/YourUsername/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools

A super common mistake is forgetting to add platform-tools to PATH—that's exactly where adb lives!

3. Apply configuration changes right away

After editing the profile file, you need to tell your shell to reload it without restarting:

  • For bash:
    source ~/.bash_profile
    
  • For zsh:
    source ~/.zshrc
    

4. Confirm the configuration is working

Let's verify the paths are set correctly:

  • Run echo $ANDROID_HOME—it should output your exact SDK path.
  • Run echo $PATH—look for your SDK's platform-tools directory in the output.
  • You can also test directly by navigating to your SDK's platform-tools folder and running:
    ./adb version
    

If this works, the issue is definitely with your PATH configuration.

5. Double-check you saved the profile file correctly

When using vi to edit the file, make sure you saved properly:

  • Press ESC to exit edit mode
  • Type :wq and press Enter to save and quit
    You can confirm the content is there by running:
cat ~/.bash_profile

6. Restart your Terminal

Sometimes changes don't take full effect until you close and re-open your Terminal window. Give that a try if the above steps don't resolve the issue.


内容的提问来源于stack exchange,提问作者Anjali

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 09:03:14