To develop something one has to install a development environment which includes various tools, libraries, IDEs etc. Android is not an exception. We’ll start from how to do this on Windows XP. Instructions for Ubuntu Linux are here.
If you are interested in building Android OS source (so-called Android Open Sourcce Project, AOSP), it is very different matter,; it requires absolutely different environment than what described below for developing Android applications, for instructions please look here.
I decided to document the installation process since I found instructions provided by Google here not very convenient. Hopefully, this my post will save time to somebody interested in Android development.
The instructions assume that you install the development environment from fresh, i.e. none of the necessary components is present on your computer.
The whole installation process may require several hours (taking into account download times for various components) and it requires following steps:
- Checking system requirements to make sure that your computer is suitable for Android development at all
- Installing Java
- Installing Eclipse IDE
- Installing Android SDK
- Installing ADT plugin
- Configuring ADT plugin
- Adding necessary folders to Windows PATH
- Building and testing your first Android application
1. Checking system requirements
You can check the system requirements here. This page seems to be up to date.
2. Installing Java
You will need Java 1.5 or 1.6 and not only JRE (Java Runtime Environment), but JDK (Java Development Kit). If you don’t have one or want to install the latest and greatest one, go here for downloads. Instructions on how to install what you downloaded can be found here.
3. Installing Eclipse IDE
Eclipse IDE can be downloaded from here. There are many flavors of it, you will need Eclipse IDE for Java Developers. This will give you the latest 3.6.1 version. If you have already earlier versions (3.5 or 3.4) and want to use them for Android development, you can do it. There is no difference between 3.6 and 3.5 as far as the installation is concerned. There is slight difference between 3.4 and 3.6 though (more about this later).
Eclipse IDE comes as a zip file, so no installation as such is required. You just unzip it into a folder you choose (I normally use for all my Eclipse installations c:\eclipse folder; but you can use whatever you want). Unzipping the file will create another folder, which in my case will be c:\eclipse\eclipse. Since I use several versions of eclipse, I normally rename the latter eclipse folder to something which reflects a version of eclipse it contains, e.g. c:\eclipse\e361. However, of course, it is up to you where to place Eclipse on your computer.
To make sure it works, you can launch the IDE. For this purpose you have to launch eclipse.exe from the root folder of the unzipped archive (which will be c:\eclipse\e361\eclipse.exe in my case). You will see this dialog:

You need to define here where on your computer you want all Eclipse projects and working files to go. I put there as you see c:\dev\android, but you can choose your own location of course.
After you enter the workspace location you will see this:

This means your Eclipse IDE has been successfully installed.
4. Installing Android SDK
This is the step which caused me the most trouble. Hopefully with my instructions it will be much simpler for you.
First you need to download Android SDK from here. There are two versions of SDK distribution for Windows out there. Google recommends the one with installer (installer_r08-windows.exe) and I used it as well. In my opinion the installer functionality is rather rudimentary and you might find installing from zip archive more straightforward; just note the instructions with regard of putting proper settings into androidtool.cfg file (see below).
The current version of SDK is 8.0. The installer you have downloaded actually contains only SDK Manager which is a tool to download and to manage SDK. So the installation is two step: first you install SDK manager from the downloaded installer and later the SDK Manager downloads and installs all other parts of SDK.
When you launch the installer, it asks you where to put SDK (I have chosen C:\tools\android-SDK-r08, but you can choose something else, of course). It unzips SDK Manager files to that directory and immediately launches SDK Manager. And here my trouble started: SDK Manager attempted to download remaining parts of SDK but failed with the not very helpful error message:
Failed to fetch URL https://dl-ssl.google.com/android/repository/repository.xml,
reason: dl-ssl.google.com
If you see something like this, don’t panic. Nothing bad happened, you will fix the issue in a minute.
First, we need to check if your computer can access the URL. The reasons why it may not be able to are numerous. It may be not connected to internet at the moment or it may be behind a firewall which blocks the URL etc.
To check the connectivity just copy and paste the URL into your browser address field and try to load the page. If you see something like the screenshot below, your computer is able to get to the URL.

I looked for the error message described above at Google (of course) and got 5560 pages returned, but none of the pages I have read helped much. So I put on my “developer hat” and figured out what was going wrong.
Basically there are two causes why you can get this or similar error message from SDK Manager even if your browser is able to retrieve the URL. Depending on your environment, you may have either one, or both, or none. I had both
SDK Manager is a Java program and a for a Java program to communicate properly over internet certain Java settings should be configured right.
The first reason why SDK Manager may fail to download SDK is use of HTTPS protocol. Many posts on Internet correctly suggest changing it in the url to HTTP (i.e. using this URL instead:
http://dl-ssl.google.com/android/repository/repository.xml
Basically, it is a certificate issue. To establish HTTPS connection with a server an application (e.g. a browser, SDK Mananger) must make sure that SSL certificate used by the server is valid. It can be done in two ways: either server’s SSL certificate can be verified with a certificate which the application has in its trusted certificate store or manually when a user confirms that the server can be trusted. Java uses just the former, browsers use both. Also, Java has its own certificate storage separate from anything else. So in my case Java didn’t have a proper certificate and that’s why it could not use HTTPS. Please note, browsers use another certificate storage (not the one used by Java), therefore I and others were able to retrieve the URL content in the browser without problems. Apparently our browsers had necessary certificates.
The second reason why SDK Manager may fail to download SDK is the fact that your computer may be behind a proxy. If you use a home computer, most likely the download does not go through a proxy. But if your computer is in a sort of local network (e.g. corporate one), the most likely it has to deal with proxy.
There are two ways to deal with the problems.
Method #1. Use SDK Manager GUI. Click on Settings on the right side of SDK Manager window.

Here you need:
- Insert proxy host URL (my-proxy.com in my case)
- Insert host port (80 in my case)
- Check Force https://… checkbox
That’s all. You can move to Available packages screen to install the packages (see below).
Method #2. All SDK Manager settings are stored in androidtool.cfg file which resides in C:\Documents and Settings\<your_user_name>\.android folder (note the period). You can put all necessary settings there:
### Settings for Android Tool
#Thu Dec 30 08:51:05 CST 2010
http.proxyPort=80
http.proxyHost=my-proxy.com
sdkman.ask.adb.restart=false
sdkman.force.http=true
Important lines are highlighted in red.
Store the file on the harddrive and you can re-start SDK Manager.
Now you need to download remaining parts of SDK. You can choose what to download on Available packages screen of SDK Manager. Google comes with recommendations (see Step 4 on the page) on what you may want to download, but I downloaded everything just for my curiosity.
There were reports that SDK installer fails with the message:
installer_r08-windows.exe (android sdk starter package) java se development kit (jdk) not found
This may have several causes. First, you must make sure that you installed Java at all. Go to command line window (cmd) and type:
java - version
It should reply with java version. If it replies something like
‘java’ is not recognized as an internal or external command,
operable program or batch file.
you probably don’t have Java. Second, you may have installed JRE (Java Runtine Environment) while you need JDK (Java Development Kit). JRE is not sufficient. Third, you may need to set JAVA_HOME variable pointing to a directory where your JDK is, something like this:
JAVA_HOME=C:\Program Files\Java\jdk1.6.0_13
For this Right click on My Computer, select Properties, click on Advanced tab, click on Environment Variables button, click New in System variables window, a dialog will pop up with two text fields. Put JAVA_HOME in the name field and path to JDK on your computer, which may be different from an example above. Click OK, again OK and again OK. Restart the computer.
5. Installing ADT plugin
ADT plugin is an addition to a standard Eclipse IDE for Java developers which makes it IDE for Android developers. “Plugin” it’s a special Eclipse term. As far as you are concerned it is just a jar file. In fact, you won’t even touch it due to excellent Eclipse software provisioning functionality.
Detailed instructions on how to install ADT plugin can be found here. You just have to keep in mind three things:
- If you are behind a proxy (which you probably already know since installing SDK Manager), you have to configure Eclipse IDE properly to make it use the proxy. For this go to Window-> Preferences-> General-> Network Connections. Enter your proxy settings there
- Follow the right set of instructions for your version of IDE. This is because Eclipse IDE versions 3.5 and later and 3.4 and earlier use different software provisioning mechanisms. You can find more about this here if you are interested, but it has nothing to do with Android
- If HTTPS URL didn’t work for you in SDK Manager, it likely wont’t work for you here, too. Try HTTP instead
6. Configuring ADT plugin
After you installed ADT plugin, you have to make it aware where Android SDK is located on your computer. For this you go to Window -> Preferences, select Android from the left panel, clock Browse and select the folder where you put Android SDK (which is C:\tools\android-SDK-r08 in my case). That’s all.
7. Adding necessary folders to Windows Path
We also need to add tools and platform-tools folders of SDK to Windows Path. Right click on My Computer, select Properties, click on Advanced tab, click on Environment Variables button, select Path in System variables window, click Edit, add folders to the path (which is ;C:\tools\android-SDK-r08\tools;C:\tools\android-SDK-r08\platform-tools in my case; don’t forget separating semicolons), click OK button, again click OK button, again click OK button, restart the computer.
8. Building and testing your first Android application
Launch your Eclipse IDE (by the way, it would be a good idea to create a shortcut to eclipse.exe; you are going to use it often, right?).
Go to File->New->Android project. You will see a dialog like this (if you use Eclipse 3.6):

- Put HelloWorldas a project name.
- Put HelloApplication as an application name
- Put org.myfirstapp as a package name
- Put MyActivity as an activity name
- Put 4 as min SDK version
- Select Android 2.3 as a build target
- Click Finish
In a few seconds you’ll see something like this:

Now you need to create a run configuration. “Run configuration” is a feature provided by Eclipse IDE (not ADT, ADT just adds functionality to it) which allows you to specify an environment your code should run into. For example for Java application you can specify what version of JRE you want to run your code with etc. This Eclipse IDE faeture is used by ADT to our (developers) advantage since it allows testing the same project with different versions of Android OS, different hardware specs of the mobile device etc.
Go to Run-> Run Configurations… in Eclipse menu. You’ll see something like this:

Click on Android Application on the left side. You’ll get a dialog titled “Create, manage, and run configurations”.
Rename the configurations from New_configuration to something meaningful, e.g. MyAndroidConfiguration. Then click Browse button and select HelloWorld project. Select Launch radio button which will activate a drop-down list located on the right from the button. Select org.myfirstapp.MyActivity activity. The click Apply and Run.
This will bring another dialog saying “No compatible targets were found…” This reminds us that we need to create an Android “device” (so-called AVD, Android Virtual Device i.e. Android device emulator) first. Click Yes. This will bring the dialog:

Please note, this dialog actually comes from SDK Manager application.
You can create and manage AVDs from SDK Manager without launching Eclipse IDE. You can do it using command-line tools, too. To launch SDK Manager GUI outside of Eclipse launch android script (android.bat on Windows) without parameters. The script can be found in tools folder of Android SDK you have installed.
Once you have access to SDK Manager GUI, click on Virtual Devices tab, then click on New button and you’ll see this Create new Android Virtual Device dialog. Enter a name (e.g. TestAVD), select Target which means what Android OS version you want AVD to run (e.g. Android 2.3), enter Size which means a size of SD card (use M for MB, K for KB). After that you should see something like that:

Click Create AVD. This brings you back to AVD chooser dialog:

Click Refresh. This will show your newly created AVD in the dialog. Select the device and click OK. This will launch AVD. Be patient – it may take some time before you see AVD GUI:

Then the emulator will load Android OS and, eventually, your application. Again, be patient. Software emulators (and not only Android ones) are often slow. It may take a minute until you’ll see the application launched. The indication that your application has been launched is this message in Console tab of Eclipse IDE:
ActivityManager: Starting: Intent { act=android.intent.action.MAIN
cat=[android.intent.category.LAUNCHER] cmp=org.myfirstapp/.MyActivity }
The you can see actual GUI of your application (you may need to click Menu button on the left panel of the emulator to see it):

Here you go… Congratulations! Your first Android application just worked!
When you want to launch the application next time, you don’t need to do again any of the above. Just launch Eclipse IDE, select the project in Eclipse IDE, select Run->Run from menu or press Ctrl+F11.
If you are serious about developing Android applications, I recommend you to learn more about Android command line tools since they are actually operating behind many of those GUIs we went through.

Read Full Post »