Setting Up the Environment

In order to work together, the Android SDK and PhoneGap need to be able to find each other. To facilitate this, you need to configure your PATH environment variable.

Your computer uses environment variables to store little bits of data that are used by programs that you run. One of these, PATH, is a list of directories that tells programs where to look for other programs. So, when you type the name of a command (such as grep or findstr) at the command prompt, your computer looks in each of the directories in your PATH for the command.

On Windows, items in the PATH are separated by a semicolon, as in: C:\Windows \System32;C:\Windows. On Mac and Linux, they are separated by a colon, as in /usr/ bin:/usr/local/bin.

To add a directory to your PATH under Windows, open up your computer's System Properties. You can get to this by left-clicking the Start Menu, right-clicking Computer (or My Computer), and selecting Properties. On Vista or Windows 7, click the Advanced System Settings link on the left. On Windows XP, click the Advanced tab.

In the dialog box that appears, click Environment Variables. Under System Variables, scroll down until you see PATH and double-click it. Be careful not to modify anything in there yet (if you make a mistake, you can always click Cancel and start over). Move the cursor all the way to the right, and add the following (with no space before the semicolon):

;C:\Android\tools;C:\PhoneGap\bin

Replace C:\Android with the location of the Android SDK (such as C:\Users\youruser name\Desktop\Android) and replace C:\PhoneGap with the location where you put Pho-neGap. Click OK and dismiss the remaining dialog boxes.

On Mac OS X or Linux, you should find a .bash_profile file in your home directory. It will be invisible, so try running this command at the command line: ls -l ~/.bash_profile

If that file exists, edit it by running the nano editor as shown below. If it does not exist but you have a .profile file (use ls -l ~/.profile to find out), edit that file instead (just replace .bash_profile with .profile): nano ~/.bash_profile

Next, scroll all the way to the bottom of the file using the arrow keys and add the following line:

PATH=$PATH:~/Android/tools:~/PhoneGap/bin

Replace ~/Android with the location of the Android SDK (such as ~/Desktop/Android/ tools) and replace ~/PhoneGap with the location of PhoneGap. Save the file by pressing Control-O then Enter. Press Control-X to exit.

Close any open Command Prompts or Terminals, then restart them. You should be able to run commands such as adb or android at the command line. If not, see http:// developer.android.com/sdk/installing.html#Installing and review the instructions there.

The utility in the PhoneGap/bin folder requires that Ruby be installed on your computer. It should be installed by default on any Mac or Linux system. If you install it on Windows (see http://www.ruby-lang.org/en/ downloads/), you may need to edit your PATH variable again and add the path to Ruby's bin directory (such as C:\Ruby191\bin). Don't forget to add a semicolon before the path entry as you did earlier.

0 0

Post a comment