Not able to access adb in OS X through Terminal, “command not found”

后端 未结 18 1507
囚心锁ツ
囚心锁ツ 2020-12-04 04:43

I have installed Android SDK and Eclipse on my Mac system. I am able to program using Eclipse and have created few sample applications. But I am still not able to access

相关标签:
18条回答
  • 2020-12-04 05:18
    1. run command in terminal nano $HOME/.zshrc

    2. Must include next lines:

      export PATH=$PATH:~/Library/Android/sdk/platform-tools
      export ANDROID_HOME=~/Library/Android/sdk
      export PATH="$HOME/.bin:$PATH"
      export PATH="~/Library/Android/sdk/platform-tools":$PATH
      
    3. Press Command + X to save file in editor,Enter Yes or No and hit Enter key

    4. Run source ~/.zshrc

    5. Check adb in terminal, run adb

    0 讨论(0)
  • 2020-12-04 05:21

    This worked for me on my MAC - 2020

    Go to directory containing adb:

    cd ~/Library/Android/sdk/platform-tools/
    

    Run adb command to list all services

    ./adb shell dumpsys activity services
    
    0 讨论(0)
  • 2020-12-04 05:23

    For Mac OS Catalina or Mojave

    Enter command to open nano editor

    nano $HOME/.zshrc
    

    Set PATH variable, means append more path as shown here

    FLUTTER_HOME="/Users/pankaj/Library/Android/flutter-sdk/flutter/bin"
    DART_HOME="/Users/pankaj/Library/Android/flutter-sdk/flutter/bin/cache/dart-sdk/bin"
    ANDROID_SDK_HOME="/Users/pankaj/Library/Android/sdk"
    ANDROID_ADB_HOME="/Users/pankaj/Library/Android/sdk/platform-tools"
    
    PATH="$PATH:$FLUTTER_HOME"
    PATH="$PATH:$DART_HOME"
    PATH="$PATH:$ANDROID_SDK_HOME"
    PATH="$PATH:$ANDROID_ADB_HOME"
    

    Now press Command + X to save file in editor,Enter Yes or No and hit Enter key.

    0 讨论(0)
  • 2020-12-04 05:26

    For zsh users. Add alias adb='/Users/<yourUserName>/Library/Android/sdk/platform-tools/adb' to .zshrc file.

    Than run source ~/.zshrc command

    0 讨论(0)
  • 2020-12-04 05:27

    Quick Answer

    Pasting this command in terminal solves the issue in most cases:

    ** For Current Terminal Session:

    • (in macOS) export PATH="~/Library/Android/sdk/platform-tools":$PATH
    • (in Windows) i will update asap

    ** Permanently:

    • (in macOS) edit the ~/.bash_profile using vi ~/.bash_profile and add this line to it: export PATH="~/Library/Android/sdk/platform-tools":$PATH

    However, if not, continue reading.


    Detailed Answer

    Android Debug Bridge, or adb for short, is usually located in Platform Tools and comes with Android SDK, You simply need to add its location to system path. So system knows about it, and can use it if necessary.

    Find ADB's Location

    Path to this folder varies by installation scenario, but common ones are:


    • If you have installed Android Studio, path to ADB would be: (Most Common)
      • (in macOS) ~/Library/Android/sdk/platform-tools
      • (in Windows) i will update asap

    • If you have installed Android Studio somewhere else, determine its location by going to:

      • (in macOS) Android Studio > Preferences > Appearance And Behavior > System Settings > Android SDK and pay attention to the box that says: Android SDK Location
      • (in Windows) i will update asap

    • However Android SDK could be Installed without Android studio, in this case your path might be different, and depends on your installation.

    Add it to System Path

    When you have determined ADB's location, add it to system, follow this syntax and type it in terminal:

    • (in macOS)

      export PATH="your/path/to/adb/here":$PATH

      for example: export PATH="~/Library/Android/sdk/platform-tools":$PATH

    0 讨论(0)
  • 2020-12-04 05:32

    For Mac, Android Studio 3.6.1, I added this to .bash_profile

    export PATH="~/Library/Android/sdk/platform-tools/platform-tools":$PATH

    0 讨论(0)
提交回复
热议问题