When you type a command in a terminal window, the shell,
a program that reads what you typed and tries to respond appropriately,
must first locate the command program on your file system. The shell
looks for commands in a list of directories stored in an environment
variable named $PATH. To see what is currently listed in the path,
type:
echo $PATH
This returns a colon-separated list of directories that should
look something like this:
/usr/bin:/bin:/usr/sbin:/usr/local/bin:/usr/x11/bin
The goal is to add the path to the AIR SDK bin directory to the
list so that the shell can find the ADT and ADL tools. Assuming
that you have put the AIR SDK at /Users/fred/SDKs/AIR,
then the following command will add the necessary directories to
the path:
export PATH=$PATH:/Users/fred/SDKs/AIR/bin:/Users/fred/SDKs/android/tools
Note: If your path contains blank space characters, escape them
with a backslash, as in the following:
/Users/fred\ jones/SDKs/AIR\ 2.5\ SDK/bin
You can use the echo command again to make sure
it worked:
echo $PATH
/usr/bin:/bin:/usr/sbin:/usr/local/bin:/usr/x11/bin:/Users/fred/SDKs/AIR/bin:/Users/fred/SDKs/android/tools
So far so good. You should now be able to type the following
commands and get an encouraging response:
adt -version
If you modified your $PATH variable correctly, the command should
report the version of ADT.
There is still one problem, however; the next time you fire up
a new terminal window, you will notice that the new entries in the
path are no longer there. The command to set the path must be run
every time you start a new terminal.
A common solution to this problem is to add the command to one
of the start-up scripts used by your shell. On Mac OS, you can create
the file, .bash_profile, in the ~/username directory and it will
be run every time you open a new terminal window. On Ubuntu, the
start-up script run when you launch a new terminal window is .bashrc.
Other Linux distributions and shell programs have similar conventions.
To add the command to the shell start-up script:
Change to your home directory:
cd
Create the shell configuration profile (if necessary) and
redirect the text you type to the end of the file with “cat >>”.
Use the appropriate file for your operating system and shell. You
can use .bash_profile on Mac OS and .bashrc on
Ubuntu, for example.
cat >> .bash_profile
Type the text to add to the file:
export PATH=$PATH:/Users/cward/SDKs/android/tools:/Users/cward/SDKs/AIR/bin
End the text redirection by pressing CTRL-SHIFT-D on
the keyboard.
Display the file to make sure everything is okay:
cat .bash_profile
Open a new terminal window to check the path:
echo $PATH
Your
path additions should be listed.
If you later create a new version of one of the SDKs into different
directory, be sure to update the path command in the configuration
file. Otherwise, the shell will continue to use the old version.