Installing the Software
The basic software components that we will need are Java, the Eclipse IDE, the Android plugin for Eclipse, and the Android Software Development Kit (SDK) and related libraries such as Google maps.
This software should work under Windows, Mac, or Linux.
Installing Java, Eclipse, and the SDK Starter Kit
To optimize flexibility, the tools required to develop with Android are installed in two stages: the basics (including an SDK "starter kit"), and then the specific Android platforms (versions of the operating system) that the developer wishes to use.
In this section we install the starter kit and in the next we install specific Android platforms.
-
If it is not already installed on your computer, get the
Java Development Kit
(JDK). You need at least Java 5 or 6 (that is, versions 1.5 or 1.6),
and you need the JDK (Java Development Kit),
not just the JRE (Java Runtime Environment). Once installed, check versions with javac -version
for the JDK and java -version for the JRE. For example, on one of my Linux Fedora 14
systems I get
[guidry@m81 androidTutorials]$ javac -version
javac 1.6.0_20
[guidry@m81 androidTutorials]$ java -version
java version "1.6.0_20"
OpenJDK Runtime Environment (IcedTea6 1.9.4) (fedora-50.1.9.4.fc14-x86_64)
OpenJDK 64-Bit Server VM (build 19.0-b09, mixed mode)
[guidry@m81 androidTutorials]$
indicating that both the JDK and the Java Runtime correspond to Java 1.6.
-
Download and install the
Eclipse IDE. Be sure to
choose "Eclipse IDE for Java Developers" (I'm using version 3.6, codenamed Helios, and version 3.5, codenamed
Galileo on my machines; install the most current version but at least 3.4 is recommended).
-
Download the current
Android SDK.
There is no installer; just uncompress in the desired directory. The Quickstart
notes on that webpage give details on how to install for Linux, Windows, or Mac
platforms. Note the directory for the SDK install since you will need to
specify it for Eclipse below. By default, the SDK files are unpacked into a
directory named
android-sdk-<machine-platform>
For example, on my Linux system
the SDK is at /home/guidry/android-sdk-linux_86. It will be convenient for
later if you add the tools subdirectory of the SDK to your path once installed,
since this will permit you to execute Android tools such as the ADB (Android
Debug Bridge) from any directory:
-
On Linux, edit your ~/.bash_profile or ~/.bashrc file. Look for a line that
sets the PATH environment variable and add to it the full path to the tools directory. If you don't see a line setting the path, you can add one: export
PATH=${PATH}:<your_sdk_dir>/tools. For example, on my Linux Fedora system:
export PATH=${PATH}:/home/guidry/android-sdk-linux_86/tools
-
On a Mac OS X, look in your home directory for .bash_profile and proceed as
for Linux. You can create the .bash_profile file if you haven't already set one up on
your machine.
-
On Windows, right-click on My Computer and select Properties. Under the
Advanced tab, hit the Environment Variables button, and in the dialog that comes
up, double-click on Path (under System Variables). Add the full path to the
tools directory to the path.
NOTE: If you install Android 2.3 you will find that the adb has been moved from the
tools to the platform-tools subdirectory of the SDK, so you should add this
directory to your path also. For example, on my Linux Fedora system,
export PATH=${PATH}:/home/guidry/android-sdk-linux_86/platform-tools
Leave the tools subdirectory in the path too, since other Android tools still reside there.
|
The SDK is in general downloaded in two or more stages, as described in more detail in
the Android
Installing the SDK document.
The current step installs the "starter package". In the next section we will use the tools
installed in this step to download specific components needed for developing and
testing applications.
-
Download and install the Android plugin for Eclipse (Android Development
Toolkit or ADT). Exact instructions will depend on the current version of
Eclipse. Details should be consulted in the
Installing the SDK document
but will be something like the following:
-
Start Eclipse and select from the Eclipse menu Help > Install New Software.
-
If the Android plugin site does not appear under the sites dropdown menu,
click the Add button and add
https://dl-ssl.google.com/android/eclipse/ (if you have trouble with this site,
you can try substituting http for https).
-
The Android site should now appear in the Available Software view. Select
it and click Install (accept license agreements, etc).
-
Restart Eclipse.
-
There should be error messages because we need to tell Eclipse how to find the
Android SDK: Choose Window > Preferences > Android (On Mac,
Eclipse > Preferences) and specify the location
of the Android SDK installed in Step 3 above.
If you encounter any problems installing the ADT, try consulting this
FAQ and
try googling the associated error strings. (As in most things Android, the Web is your best help desk since it is likely that you are not the first person who has encountered your problem.)
-
Add Android platforms and other components required for the specific
projects you will develop using the tools installed in Step 3, as described in the next section.
Installing Specific Android Platforms
The SDK uses a modular structure that divides the major parts of the SDK---Android
platform versions, add-ons, tools, samples, and documentation---into separately installable components. The SDK starter package installed in
Step 3 includes only a single component: the SDK Tools. To develop an Android
application, you also need to download at least one Android platform, although downloading additional components is often useful
(see
Adding SDK Components for more details).
The types of components in the SDK repository are:
-
SDK Tools (pre-installed in the Android SDK starter package in Step 3 and
found in the tools subdirectory of the SDK). This contains the full set of SDK tools
for developing, debugging, and testing.
-
Android platforms---An SDK platform is available for each
Android platform (for example, Android
2.1, Android 2.2, ...). Each platform component includes a fully compliant
Android library and system image, sample code, emulator skins, and any
version-specific tools. You must install at least one of these, corresponding to
the Android version(s) your application will target.
-
SDK Add-Ons---Provide a development environment for specific Android
external libraries or a customized (but fully compliant) Android system image. For
example, the Google APIs Add-On gives
your application access to mapping capabilities through the
com.google.android.maps library. If your application uses these capabilities,
the corresponding Add-On is mandatory.
-
USB Driver for Windows---Contains Windows drivers necessary to run and debug your applications on an
actual device. You do NOT need the USB driver unless you plan to debug your
application on an actual device, and you do NOT need these
drivers if you develop on Mac OS X or Linux.
-
Samples---Sample code and apps available for each Android development
platform.
-
Documentation---Local copy of the latest documentation for
the Android framework API.
See recommended components for information about
which components are required and which are optional.
To install additional components of the SDK:
-
Open Eclipse.
-
Select Window > Android SDK and AVD Manager. (Note that you can also
launch this window by issuing the command "android" with no arguments in a shell
window, assuming you have put the SDK tools directory in your path as instructed
above; otherwise you will have to use the full path to the android command.)
-
In the left panel of the resulting window select Installed Packages to see
what is installed, and Available Packages to see what is available that is not
yet installed. Under Available Packages, check the boxes for components that
you wish to install (see the following figure).
For our purposes, let us select all the platforms, Google
API add-ons, and docs for versions 1.5, 1.6, 2.1, 2.2, 2.3, and Honeycomb (3.0) of Android. (This will
allow us to target the latest Android versions, but also to test backward
compatibility with earlier versions.) After selecting, click the Install
Selected button, and accept any license requirements, etc. After installation,
these new components should appear if Installed Packages is selected in the left
panel, as illustrated in the following figure
If you do not have all these packages installed, go back to Available Packages and check that all available packages have been selected.
-
Close the Android SDK and AVD Manager window.
You should now have all the
components required to begin developing an Android application. A good way to test
your installation is to install and run a sample Android package, as described in the next section.