2010-10-18

Getting started with android

The goal of this article is to present in a concise way how to configure development environment for android platform.

Here are the necessary steps:

  1. Download Android SDK

  2. Download Eclipse

  3. Download Eclipse plug-in for android (ADT Plugin for Eclipse)

  4. Download Android Sources and attach them to eclipse



1. Download Android SDK


Download the newest version of the SDK from: http://developer.android.com/sdk/index.html. Unzip SDK in desired location (SDK_HOME).
Run the SDK Manager and download desired / all platform versions.

2. Download Eclipse


Download eclipse from: http://www.eclipse.org/downloads/.
At the time of writing, there was no ADT Plugin for Eclipse for version 3.6 (Helios). I have been using Eclipse 3.5 (Galileo). Unzip eclipse in desired location.

3. Download Eclipse plug-in for android (ADT Plugin for Eclipse)


Launch eclipse. Open menu Help -> Install New Software. Add new software site location.
Enter "Android" as name and https://dl-ssl.google.com/android/eclipse/ as location.
Install all available software. Restart eclipse.
Open menu: Window -> Preferences. You should have Android option available in options tree.
Set SDK location to SDK_HOME (path to directory SDK directory).

4. Download Android Sources and attach them to eclipse


Downloading sources is a bit more complicated, but you won't get far without them.
Currently there is no source package available on line so you have to download them from GIT repository.

If you don't have GIT installed, you have to download it.
For windows you can use newest version from http://code.google.com/p/msysgit/
(e.g. http://code.google.com/p/msysgit/downloads/detail?name=PortableGit-1.7.3.1-preview20101002.7z.

With GIT installed you can download sources from: http://android.git.kernel.org/
You can download all sources, but the ones you need are in: platform/frameworks/base.
Execute commands:
mkdir android-sources
cd android-sources
git clone git://android.git.kernel.org/platform/frameworks/base.git
Sources you need are in folder: base/core/java
You have to copy these sources into "sources" folder for platform you are using.
mkdir SDK_HOME/platforms/android-VER/sources - replace VER with the API version you are using
cp -R base/core/java/* SDK_HOME/platforms/android-VER/sources

Restart eclipse and open any android class (e.g. android.app.Activity), sources should be available.

Remark: Downloaded sources are probably the newest version and may not be exactly the API version you are using. Anyway they worked fine for me.

Details about attaching SDK sources to eclipse can be found here:
http://stuffthathappens.com/blog/2008/11/01/browsing-android-source-in-eclipse/

5. Test configuration


Open menu: File -> New -> Project -> Android Project. Enter some project name.
Choose option "Create project form existing source" and select some project from SDK examples
(e.g. SDK_HOME\samples\android-7\ApiDemos). Choose some API version (Build target).
Launch project (Run as ... -> Android project).

First start of the emulator may take some time (up to 5 minutes). Please be patient.




Author: Jakub Marciniak (jakub.marciniak (at) apilia.pl)