We’ve previously published a guide to setting up ADB on your Mac or Windows PC. At the end of that article I mentioned that you can add the platform-tools directory to your $PATH. What this does is allows you to simply type “adb” instead of “/Users/username/really/long/path/etc/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb”, or navigating to that directory before attempting to run the ADB or fastboot tools. Today I’ll show you how this is done.
Every operating system is slightly different, but the principle is the same. $PATH represents a list of directories in which the system will look for an executable file when it’s requested. You can add to it to make it easier to run executables without having to specify the full path to it, so adding the path to platform-tools ensures you’ll always be able to run anything in that directory.
Mac or Linux
To achieve adding the SDK Platform Tools to your $PATH for Mac or Linux you need to follow a few simple steps
- Open up a terminal and navigate to home directory by typing cd ~
- Create file .bash_profile by typing touch .bash_profile
- Open the file with TextEdit by typing open -e .bash_profile
- Insert the line into TextEdit export PATH=$PATH:/Users/username/custompath/sdk/platform-tools/
- save file and reload file by typing source ~/.bash_profile
To check if adb was set into path type adb version, if you’ve been successful you’ll see something like this
To achieve adding the SDK Platform Tools to your $PATH for Windows you need to follow these steps courtesy of Computer Hope.
Before you start, you’ll need to know the full path to your platform-tools directory.
- Windows 8: From the Desktop, right-click the very bottom left corner of the screen to get the Power User Task Menu. From the Power User Task Menu, click System.
Windows Vista / Windows 7: From the Desktop, right-click the Computer icon and select Properties. If you don’t have a Computer icon on your desktop, click the Start button, right-click the Computer option in the Start menu, and select Properties.
- Click the Advanced System Settings link in the left column.
- In the System Properties window, click on the Advanced tab, then click the Environment Variables button near the bottom of that tab.
- In the Environment Variables window (pictured below), highlight the Path variable in the “System variables” section and click the Edit button. Add or modify the path lines with the paths you want the computer to access. Each different directory is separated with a semicolon as shown below:
- Add a semicolon at the end (to separate it from the previous directory), and paste the path to your platform-tools directory at the end.
You can find out more about ADB and what it can be used for on the Android Developer site.