I made a bold statement at a team meeting the other day that you could go from a vanilla windows installation to writing a “hello world” application for android in an hour.
Providing you've a half decent internet connection, here's what you need to do.
1. Install Java
We’re going to develop our app using Java so we need to install the Java SE Development Kit 7 (choose your platform) and download it. Install it using the default options.
2. Install Eclipse
Eclipse is the development IDE we’ll use to develop our app in. (Note to all the Visual Studio users: “We’re through the looking glass here people! Just go with it. It’s fine….”)
Browse to the Eclipse download page and select “Eclipse Classic”.It doesn’t have an installer, it can be simply unzipped and ran so extract the contents of the zipped folder to your "program files" folder. It's nearly 200mb so takes a while to unzip though! Create a shortcut of the Eclipse.exe file on your desktop, then you're good to go.
3. Install the Android Software Development Kit
Download the Android SDK and install it.
NB There is currently a spooky bug in the Android SDK installer: When you install the SDK, you may come across one the wizard screens saying "Java SE Development Kit (JDK) not found".
Providing of course that you have installed the Java SDK(!), to get round this you need to simply hit the back button, then "Next" again, and the wizard will say its now been found!
Hit “Next” and select the default destination folder for the Android SDK then continue with the installation. When you reach the end of the wizard, ensure the Start SDK Manager check box is ticked then hit finish:
This will then fire up the SDK Manager app, allowing you to choose the platform images you wish to download. I just went with the default platforms for the time being. It did take a while to download so please be patient:
You may get a message come up asking you if you want to restart the ABD. Hit “Yes” and you're almost done.
When the packages are installed (above), hit "close" then close down the Android SDK manager. We'll carry on with the configuration from within eclipse now.
4. Configure Eclipse for Android Application Development
Fire up eclipse and select a default workspace.
You know need to install the Android Development Tools(ADT) Plugin. Follow the instructions at http://developer.android.com/sdk/eclipse-adt.html to do this.
After you've restarted eclipse, you need to manually set the location of the Android SDK.
- Select Window > Preferences then in the left hand list, select "Android".
- Browse to the location of the SDK location we downloaded earlier and hit "Apply". You'll see the SDK target list populate.
NB: There is a bug in how the path to the Android SDK is resolved. If you have installed the SDK to “C:\Program Files (x86)\Android”, you need to enter “C:\Progra~2\Android\android-sdk” if you’re installing to a 64-bit machine or “C:\Progra~1\Android\android-sdk” if your installing to a 32-bit machine:
…more on this issue can be found on Stack Overflow.
5. Adding a Virtual Android Device
When we're developing android applications, we'll want to test them locally before deploying them to a device. To do this, we'll need to create a virtual device that we will run our app on:
- Click on the AVD Button (above) on the eclipse toolbar and create a new Virtual Device, imaginatively called "TestDeviceOne".
- Select a target O/S of "Android 2.2 - API Level 8" and SD Card size of 1 GiB
It'll take a couple of seconds to create the device but then it should appear in the device list as so:
6. Creating a Hello World project
Just to get up an running, we'll start a new Android Project from the toolbar (above) and call the project HelloWorld and select the Build Target as Android 2.2. and we’ll enter a package name of com.helloworld.demo
Hit the "Run As" (above) button and select "Android Application" as the way to run the project.
The virtual device will now spin up and load your Hello world app. (NB The virtual device takes a while to get going, but you can keep it open once it's running while you work on your app).
There you have it. More “Hello Worlds” than a Wrox Demo…!
Let me know if I’ve missed anything out or if you managed to get the process done in less than an hour!