How to install Android SDK in Linux

Download the Android SDK

PhoneGap works in conjunction with the Android SDK, so before we can get started with PhoneGap, we need to download and install the Android SDK itself. Follow the steps here to do so:

  1. Navigate to the Android SDK download page (http://developer.android.com/sdk/index.html) and download the package appropriate for your platform. If you are on Windows or Linux, you will need to install Java (see http://java.sun.com/javase/downloads) first. My development machine is a MacBook Pro running Mac OS X 10.6 so in my case, the appropriate package is android-sdk_r06-mac_86.zip for Mac OS X (Intel) (Figure 7.1, “Download the appropriate Android SDK for your development machine.”). (The 06 in the SDK file name refers to the version of the Android SDK and may be different at the time you read this.)

    Warning

    Java comes preinstalled on Mac OS X and is available in most Linux package managers. If you install it on Windows, you'll need to set your JAVA_HOME environment variable. Follow the instructions in the section called “Setting Up the Environment”, but instead of modifying the PATH environment variable, create a new environment variable called JAVA_HOME and set it to the directory that Java was installed in (such as C:\Program Files\Java\jdk1.6.0_21).
    Figure 7.1. Download the appropriate Android SDK for your development machine.
    Download the appropriate Android SDK for your development machine.


  2. Unzip the downloaded archive to whatever directory you like. I’m going to put mine on the desktop.

    Warning

    On Windows, you won't be able to use the ~ shortcut for your home directory. Also, you should avoid spaces in the path names, so if you are on Windows XP (which puts at least two spaces in your home directory due to home directories residing in Documents and Settings), you should create a directory such as C:\Source instead of putting things on your desktop.
  3. For simplicity sake, I’m going to rename the unzipped SDK directory to "Android".

  4. Launch the Terminal application and navigate into the tools subdirectory of the Android SDK directory. If you’ve been doing the same thing I’ve done (put it on your desktop and renamed the directory), the command to do this is:

    cd ~/Desktop/Android/tools/

    On Linux, the command will be the same (if you put the Android directory in the Desktop subdirectory of your home directory). On Windows, the command would be something like:

    cd %USERPROFILE%\Desktop\Android\tools

  5. Enter the following command to launch the Android SDK and AVD Manager. On the Mac or on Linux, the command is:

    ./android

    On Windows, the command is:

    android

  6. When the Android SDK and AVD Manager window opens, click on Available Packages in the left sidebar. You should see a single item appear in the Sites, Packages, and Archives panel (Figure 7.2, “The Android SDK and AVD Manager is used to download SDK packages for particular versions of the Android OS.”).

    Figure 7.2. The Android SDK and AVD Manager is used to download SDK packages for particular versions of the Android OS.
    The Android SDK and AVD Manager is used to download SDK packages for particular versions of the Android OS.

  7. Check the box next to https://dl-ssl.google.com/android/repository/repository.html to install all of the available packages and archives. (See Figure 7.3, “Check the box next to https://dl-ssl.google.com/android/repository/repository.html and click the Install Selected button.”)

  8. Click the Install Selected button in the lower right corner of the window.

    Figure 7.3. Check the box next to https://dl-ssl.google.com/android/repository/repository.html and click the Install Selected button.
    Check the box next to https://dl-ssl.google.com/android/repository/repository.html and click the Install Selected button.

  9. A window will appear asking you to accept the license terms. Read the terms, check the box next to Accept, and click the Install button to begin your download (Figure 7.4, “Read and accept the platform description and license, and click the install button.”).

    Figure 7.4. Read and accept the platform description and license, and click the install button.
    Read and accept the platform description and license, and click the install button.

  10. When your download completes, click Close to close the download window.

  11. On Mac OS X, select Quit Android from the Android menu to leave the Android app. On Windows or Linux, simply close the window.

Comments