OUYA Game Development by Example
上QQ阅读APP看书,第一时间看更新

Time for action – editing PATH on Mac OS

If you're using Mac OS, your PATH variable can read paths from your .bash_profile script. If you aren't familiar with it, you may not have one yet; so in that case, you'll need to create it by performing the following steps:

  1. Start up the Terminal and enter cd ~/ to navigate to your home folder.
  2. Type touch .bash_profile to create it.
  3. Enter open -e .bash_profile to open it for editing.

Once you have your bash profile open, add the following lines to it:

export ANDROID_HOME="~/Development/adt-bundle-mac-x86_64"
export PATH=$PATH:$ANDROID_HOME/sdk/tools
export PATH=$PATH:$ANDROID_HOME/sdk/platform-tools

Tip

If you've changed your default shell from bash to a different shell, your profile may be named differently. For instance, if you're using zsh, you'll want to edit ~/zshrc instead of ~/.bash_profile. Check your shell's documentation for the exact name and location of the profile file.

Now that you've edited your PATH variable, you'll want to refresh it by typing the following command:

source ~/.bash_profile

To ensure the new directories were added to the PATH variable correctly, write the following line to display the PATH variable:

echo $PATH

After verifying that your PATH variable contains the directories that we added in this section, prepare for the next step by starting the Android SDK manager with the following command, and then close the Terminal:

android sdk

What just happened?

You've just edited your PATH variable permanently by adding a few directories to PATH in your profile file, which is loaded every time the computer starts up, so you'll never need to edit it again. Your profile is typically a hidden file starting with a period, and its specific name depends on whatever shell you're running (usually bash, by default).

Adding the Android package directories to your PATH variable enables you to send commands to the OUYA console using the Mac OS Terminal, which will be a useful tool when you get into development.

The next tutorial outlines how to make this change on a Windows computer. Feel free to skip over it and advance to the section titled Installing packages with the Android SDK if you don't have a Windows computer or don't wish to develop on it at this point in time.