featuredtutorials

Getting Started With Android – Setting Up The Development Environment

[toc=”2,3″ title=”Table of contents”]
This is a walkthrough on how to get started developing android applications in windows with Eclipse. I will be using Windows 7 but the steps are similar in Vista and XP. This article assumes little prior knowledge about Android.

The reason for using Eclipse is because there exists an Android development plug-in for Eclipse, which makes things easier for us developers. Also, Eclipse is a good and Open Source IDE. Eclipse can also be used for other languages such as PHP, C++ and Ruby, it also has a very good Subversion plug-in for using repositories.

Developing Android applications, and using these tools described here, does not cost you anything.

Some short explanations

  • Java JDK: This is a collection of Java development tools
  • Android SDK: This contains a bunch of development tools.
  • AVD: AVD stands for Android Virtual Device, and is a device you can use to test your applications on.
  • ADT: Android Development Tools is a plugin for Eclipse, which makes developing Android applications much easier. With this plug-in you can easily create new android projects, create GUI for your application, manage internationalization, debug your application, and testing you app on your AVD, or directly on your real device.

We will first need to get a couple of tools, before we install the tools, and configure them properly.

Downloading tools

First off, if you don’t have Sun Java JDK installed already, go ahead and download it.
Use the 32 bit version, as pointed out in the comments below.

Then download Eclipse IDE for Java Developers from here.
(I am running 64 bit Windows 7, but I use the 32 bit Java SDK and Eclipse versions since that works best together)

Then get the android SDK for Windows from here.
The current filename is android-sdk_r07-windows.zip.

And that’s all the tools we need.

Installing the tools

I would recommend installing tools like these to a folder that has a path without spaces in it.
I have created a directory called C:\dev for my Android development, so I will install Eclipse and the Android SDK into that folder:  C:\dev\eclipse and  C:\dev\android-sdk-windows

Java

First install Java JDK, which also will install Java JRE.

Create a new environment variable to point to where you installed Java JDK.
The default JDK location is C:\Program Files\Java\jdk1.6.0_22

Go to Control Panel ->Advanced system settings -> Click the Environment Variables button

Choose the PATH variable, click Edit, and add the location to you JDKs bin folder, at the end.

In my case that is:   ;C:\Program Files\Java\jdk1.6.0_22\bin

Remember to add  the ; to separate this path from the other paths.

Then hit Ok and Ok.

To verify that Java was installed correctly, open a command window and run this command:  java -version

And you should see something like java version “1.6.0_22″ etc… Then you know the installation was successful, and we can continue.

TIP: to set the JDK bin path in the PATH variable, you could also run this from a command window:
path = %PATH%;C:\Program Files\Java\jdk1.6.0_22\bin
Then close the command line window, open a new one, and test with the command: java -version

Android SDK

To install the Android SDK, simply unzip the file to you C:\dev folder, or any other folder of your choice.
I put my SDK in my dev folder, so the path to it becomes C:\dev\android-sdk-windows

You can add the tools directory in your SDK folder to your PATH variable (like we did above) to get easy command line access to various tools.

Eclipse

To install Eclipse, simply unzip the .zip file. I put Eclipse in my C:\dev\eclipse folder.

Android Development Tools (ADT)

The ADT is a plugin for Eclipse, we can install plug-ins with Eclipse’ own plug-in manager, so start Eclipse.exe

First time you start Eclipse, you can select a workspace, Eclipse uses the workspace to store your android projects, plug-ins etc.  I like to know where I find this folder, so I put it in my dev folder.

You now have Eclipse running, and we need to install the ADT plug-in.

In the menu bar, go to Help -> Install new software

(or Software updates if you have Eclipse 3.4)

Enter the location where to download the ADT from, which is

https://dl-ssl.google.com/android/eclipse/

And hit enter,  you should now see the Developer Tools in the list below. Check all of them and hit Next.

On the next screen for reviewing your updates, hit Next. On the next screen with licenses, accept, and hit next.

After a little while you get a message that says

“Warning: You are installing software that contains unsigned content….” Hit Ok.

When the installation is finished, hit Restart Now.

Tip: Sometimes the ADT plug-in gets updated, you can install those updates by going to the Check for updates under the Help menu And then check Android DDMS and Android Developer Tools if any updates are available.

Configuring

After installing our tools, we need to configure them properly.

Configuring the ADT plug-in

Now we need to show the ADT plug-in where we installed our android SDK.

In the menu  bar, hit Window ->Preferences, and go to the Android tab.

Now browse to the location of where you installed the SDK, mine was C:\dev\android-sdk-windows.

Hit Apply, and OK.

You now (hopefully) have your Eclipse IDE set up right, and we are ready to start developing. But first, we need an android device to deploy and test our applications on.

Installing an Android Virtual Device

Hit the little box with a green android in it in the Eclipse menu bar , this launches the Android SDK and AVD Manager.

Under Available packages, you can choose which device you want to test your applications on.
For example API7 is Android 2.1.

Check the API7 packages, Usb driver package, Market licensing package, and the samples, and hit the Install selected button

On the next screen, check Accept all and hit Install

The download may take a couple of minutes depending on your internet connection.

When it is finished, select Restart Eclipse and then Close.

Close the AVD manager and restart Eclipse.

Open Window -> Preferences -> Android, and make sure an SDK Target is selected in the list, otherwise choose “Android 2.1-update1″, Hit Apply and OK.

Open the Android SDK and AVD manager , and then the Virtual devices menu.
You have earlier downloaded the files for the android virtual device, now it’s time to install it.

Hit New, Enter a name for your device, and choose the android 2.1 API 7 that we installed.
You may give it a couple of MB SD Card storage too.

Then hit Create AVD. We now have an AVD installed, if you want to launch it, select it, hit Start… and then Launch.

It always takes some time to start the AVD, but when it is booted, you should see this:

Final words…

You are now ready to begin developing android apps!

Thank you for following this tutorial.

If you want to try out the new Gingerbread (Android 2.3) AVD, you can check out this similar guide on how to get it up and running!