Introduction to Android Application Development Part 3: Installing Android 2.0 SDK on a Mac

Here’s a repost of an earlier blog post for everyone at the Humanities Gaming Institute.

Lately I’ve updated to Android 2.0 SDK.  In the process I noticed that things were slightly different.  Following my motto of “Scratching my head so you don’t have to,” I’ve decided to document the new process of installing the SDK from scratch.  (And I mean from scratch… I just freshly installed Mac OSX yesterday.)

System Details:
Here are some details on my system so you know what environment I’m working in:

Picture 1

Essentially I’m running a white MacBook about a year and a half old… Theoretically this install should work with any Mac.

Step 1: Get Eclipse
If you already have eclipse feel free to skip this step, but I was serious about documenting the process from scratch…

Download the version of Eclipse for your purposes at http://www.eclipse.org/downloads/.  I download the Eclipse IDE for Java Developers because I mostly use Eclipse for Android development.  Under this header I choose the Mac Cocoa 32 bit download, as the Carbon download is soon to be deprecated.

Picture 2

Unzip the downloded tar.gz file somewhere convenient.  I just unzipped it to my ‘Documents’ folder.  Inside this folder there is an eclipse executable with the familiar eclipse logo.  (I just add eclipse to my dock items afterwards so I don’t have to hunt for it again.
Picture 3
Step 2: Download the Android SDK

Grab the Android SDK from the Android website.  Choose the proper SDK for your environment (which would be Mac OSX) and download.  Unzip this to an appropriate place as well.  Again I just dump it to my documents folder.

Step 3: (Optional but highly recommended) Add /tools to you $PATH variable

Now to make your life easier if you ever plan on doing anything remotely involved with android, add the /tools directory within the SDK folder to your $PATH variable.  This allows you to easily invoke the tools found in the folder, such as adb quickly from a terminal window.
To edit your path variable:

  1. Open a terminal window
  2. Edit your .bash_profile file (its ok if this doesn’t exist yet.  I just edit by nano .bash_profile
    )
  3. Add export PATH=${PATH}:<your_sdk_dir>/tools to the open file.  I usually make sure i get this right by popping open another terminal window and cd-ing until I’m in the /tools directory, typing pwd and copying and pasting the results.  My .bash_profile file now reads: export PATH=${PATH}:/Users/myusername/Documents/android-sdk-mac/tools
  4. Save and close.  To do this with nano use <ctrl>+<x> , <y>, <enter>
  5. To test whether your $PATH variable has changed, close all terminal windows, open a new one and type in $PATH.  Something like -bash: /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/Users/usernamehere/Documents/android-sdk-mac/tools: No such file or directory should appear.

Step 4: Install the Eclipse Plugin
Now we have to install the Eclipse plugin for Android development

  1. Open Eclipse
  2. Goto Help > Install New Software
  3. Click Add
  4. In the resulting popup box type Android ADT Plugin (or something similar) into the name field
  5. Type https://dl-ssl.google.com/android/eclipse/ into the Location field
  6. Press OK
  7. Check the box next to ‘Developer Tools’Picture 4
  8. Click Next.
  9. Accept the liscense agreememts
  10. Click Finish

At this point, the plugin should install.  After installation Eclipse will prompt you to restart it.

Step 5: Adding SDK Components
Here’s where things are different.  Instead of installing the SDK for a given version of Android, we now install SDK Components for that version of Android.  This allows us to test against many different versions of Android easily and make sure that that prized application we’ve worked on for the past several months works on Android 1.5, 1.6, 2.0, and over 9,000

  1. Open the preferences pane.  This can be done easily by the keyboard shortcut <cmnd> + <,>.
  2. Click Android on the left pane as shown below
    Picture 5
  3. In the field SDK Location fill in the directory where you unzipped the SDK
  4. Click Apply then Ok
  5. Go to Window > Android SDK and AVD Manager
    Picture 6
  6. Goto Available Packages, check the box next to the website listed, and check the components you want to install.  Click Install Selected. Accept all and Install. This will be how you install new Android versions.

Now you should be ready to go and start developing Android applications!  If you have any trouble following anything listed above, leave a comment and I’ll help remedy the situation.