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

后端 未结 18 1508
囚心锁ツ
囚心锁ツ 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:35

    The problem is: adb is not in your PATH. This is where the shell looks for executables. You can check your current PATH with echo $PATH.

    Bash will first try to look for a binary called adb in your Path, and not in the current directory. Therefore, if you are currently in the platform-tools directory, just call

    ./adb --help
    

    The dot is your current directory, and this tells Bash to use adb from there.

    But actually, you should add platform-tools to your PATH, as well as some other tools that the Android SDK comes with. This is how you do it:

    1. Find out where you installed the Android SDK. This might be (where $HOME is your user's home directory) one of the following (or verify via Configure > SDK Manager in the Android Studio startup screen):

      • Linux: $HOME/Android/Sdk
      • macOS: $HOME/Library/Android/sdk
    2. Find out which shell profile to edit, depending on which file is used:

      • Linux: typically $HOME/.bashrc
      • macOS: typically $HOME/.bash_profile
      • With Zsh: $HOME/.zshrc
    3. Open the shell profile from step two, and at the bottom of the file, add the following lines. Make sure to replace the path with the one where you installed platform-tools if it differs:

      export ANDROID_HOME="$HOME/Android/Sdk"
      export PATH="$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools:$PATH"
      
    4. Save the profile file, then, re-start the terminal or run source ~/.bashrc (or whatever you just modified).

    Note that setting ANDROID_HOME is required for some third party frameworks, so it does not hurt to add it.

    0 讨论(0)
  • 2020-12-04 05:35
    1. Simply install adb with brew

      brew cask install android-platform-tools

    2. Check if adb is installed

      adb devices

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

    This is how it worked for me

    first I find my platform-tools than I was using zshrc instead of bash_profile so I run this command first

    echo 'export PATH=$HOME/Library/Android/sdk/platform-tools/' >> ~/.zshrc
    

    next refresh terminal

    source ~/.zshrc
    

    Check if it worked

    adb devices
    

    result of this command must be something similar to this if so then it worked.

    List of devices attached
    emulator-5554   device
    
    0 讨论(0)
  • 2020-12-04 05:37

    In addition to slhck, this is what worked for me (mac).

    To check where your sdk is located.

    1. Open Android studio and go to:

    File -> Project Structure -> Sdk location

    1. Copy the path.

    2. Create the hidden .bash_profile in your home.

    3. (open it with vim, or open -e) with the following:

    export PATH=/Users/<Your session name>/Library/Android/sdk/platform-tools:/Users/<Your session name>/Library/Android/sdk/tools:$PATH
    

    1. Then simply use this in your terminal: . ~/.bash_profile

    SO post on how to find adb devices

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

    For some reason when installed Android Studio 3.6.1 the adb file was actually in $ANDROID_HOME/platform-tools/platform-tools. not sure if this is a bug with my installation or what but this fixed it for me.

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

    For me, I ran into this issue after switching over from bash to zsh so I could get my console to look all awesome fantastic-ish with Hyper and the snazzy theme. I was trying to run my react-native application using react-native run-android and running into the op's issue. Adding the following into my ~.zshrc file solved the issue for me:

    export ANDROID_HOME=~/Library/Android/sdk
    export PATH=${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools
    
    0 讨论(0)
提交回复
热议问题