Setting Up the Development Environment on Windows

In this section, you'll configure the tools to create your first Android application on the Windows platform. If you're not a Windows user, skip to the next section, which explains how to configure the tools for a Linux distribution. Even though the steps describe configuring the environment on the Windows Vista platform, they are identical for other releases of the Windows operating system.

1. Download and install the Java Standard Edition Development Kit. This installs the complete set of tools and libraries for developing Java applications. Make sure the version that you install is either JDK 5 or a later version (JDK 6 preferred).

2. Download the ANT binaries. Unzip the zip file using your favorite utility.

3. Download the Android SDK. Unzip the zip file using your preferred zip utility.

4. To ensure that you can run the command-line tools from JDK, ANT, and Android, it is convenient to set some environment variables within Windows. This ensures that you can run the tools from any directory. Setting these variables also helps these tools find each other. For example, ANT relies on JDK, so setting the necessary environment variables will help ANT find the path to the JDK tools.

To set these variables, go to the Control Panel, select System and Maintenance, and then select System. In the System window, select Advanced System Settings and select Environment Variables (see Figure 11.1). Create the user variables ANDROID_HOME, JAVA_HOME, and ANT_HOME to point to the respective directories where you have extracted or installed Android, JDK, and ANT. Next, create a PATH user variable and set the value to %PATH%;%JAVA_HOME%\bin;%ANDROID_HOME%\ tools;%ANT_HOME%\bin. This enables you to access the command-line tools from any location.

Environment variables contain variables that many applications installed in your system might share. Make sure you don't delete any existing environment variables, because other programs might depend on them. Also make sure that you set only the user variables, not the system variables. User variables are settings for the current logged in user and the system variables are settings for all users of the system. Although setting these variables as system variables makes them available for all users in your system, it increases the chances of mistakenly changing something that other programs use.

FIGURE 11.1

Setting environment variables.

5. To ensure that you have set the environment variables correctly, open a command prompt and try the commands javac, ant, and adb. If you have set everything correctly, you should get usage information on how to use those commands. If you get an error with the message that the command is not recognized as an internal or external command, you must revisit the created variables and make sure that you have set the information correctly.

6. Download Eclipse. Unzip the zip file using your preferred zip utility. If required, create a shortcut to your desktop for eclipse.exe to invoke Eclipse easily.

0 0

Responses

  • Andrea
    How to use windows environment variables on android?
    7 years ago

Post a comment