Trying to add adb to PATH variable OSX

前端 未结 14 1224
遇见更好的自我
遇见更好的自我 2020-11-28 18:04

I am trying to develop for android and I want to add the adb to my PATH so that I can launch it really easily. I have added directories before by f

相关标签:
14条回答
  • 2020-11-28 18:34

    Android Studio v1.2 installs the adb tool in this path:

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

    So it goes like this:

    1. Run Terminal
    2. run adb version and expect an error output
    3. touch ~/.bash_profile
    4. open ~/.bash_profile
    5. add the above path before the 'closing' :$PATH
    6. source ~/.bash_profile
    7. run adb version and expect an output

    Good luck!

    0 讨论(0)
  • 2020-11-28 18:36

    Alternative: Install adb the easy way

    If you don't want to have to worry about your path or updating adb manually, you can use homebrew instead.

    brew cask install android-platform-tools

    0 讨论(0)
  • 2020-11-28 18:38

    In order to make the terminal always have the file ~/.bashrc and there put the path you wish to use, by adding:

    export PATH=$PATH:/XXX
    

    where XXX is the path that you wish to use.

    for adb, here's what i use:

    export PATH=$PATH:/home/user/Android/android-sdk-linux_x86/platform-tools/
    

    (where "user" is my user name).

    0 讨论(0)
  • 2020-11-28 18:38

    I added export PATH=${PATH}:/Users/mishrapranjal/android-sdks/platform-tools/ into both places .bash_profile and .profile to make sure it works. Still it wasn't working and then I looked at sarnold's tip about restarting terminal and it worked like a charm. It saved my time of adding every time this into the PATH whenever I had to run adb. Thank you guys.

    0 讨论(0)
  • 2020-11-28 18:39

    If anyone can't seem to get there .bash_profile file to take any new Paths AND you have other commands in that file (like alias commands) then try moving the PATH statements to the top of the file.

    That is the only thing that worked for me. The reason it worked was because I had some typos in my alias commands and apparently this file throws an error and exits if it runs into a problem. So that is why my PATH statements weren't being run. Moving it to the top just let it run first.

    0 讨论(0)
  • 2020-11-28 18:45

    I use zsh and Android Studio. I use a variable for my Android SDK path and configure in the file ~/.zshrc:

    export ANDROID_HOME=/Applications/Android\ Studio.app/sdk
    export PATH="$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools:$PATH"
    

    Note: Make sure not to include single or double quotes around the specified path. If you do, it won't work.

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