< Browse > Home / mobile, programming / Blog article: Getting ready for Android development

| Mobile | RSS

Getting ready for Android development

August 13th, 2009 | 1 Comment | Posted in mobile, programming

If you want to get started with Android development, you’ll need to setup some things like the SDK, an IDE and an AVD. In this post I will walk you through the setup of these things, creating a test project and getting the project running on the emulator. When you’ve done all that, you are ready for some Android development, which I will cover in future posts.

Download the Android SDK

First of all, you need to download the Android SDK. You can find on the Android developers site, in the SDK section. I’m using the mac x86 1.5 R3 version in this tutorial which is 175MB when writing this post.
When downloaded, extract the zip file (I recommend you do this in a folder you know will never move, like /programming/sdk) and we are finished with this folder for now.

Installing Ecipse and the Android Development Tools

I’m using Eclipse for most of my development and it looks like google did a great job on their Android Eclipse plugin, so that’s what we’ll use for our development.

  1. In order to use this plugin, we will need Eclipse itself. Download Eclipse for java developers from the Eclipse site. I recommend the Cocoa version.
  2. Extract the downloaded file into your /Applications folder and fire up Eclipse.app.
  3. In your application menu select: Help > Install New Software …
  4. Hit the Add button and give a name that makes sense (“adt” or “android development” tools for example). For location, enter https://dl-ssl.google.com/android/eclipse.
    Add new plugin site
  5. When you push the Ok-button, Eclipse will load the the available components. Select Developers Tools (make sure the nested components are checked as well) and hit next.
    install
  6. You’ll be presented with an overview of installations, just click next. Then accept the license and hit finish. Eclipse will now install ADT.
  7. Restart Eclipse.
  8. Now we need to let ADT know where he (or she) can find our SDK. Go to your preferences (windows: window > preferences. Mac: Eclipse > preferences).
  9. In the left panel, select Android (you might get a warning your SDK is not setup yet, but you can ignore that because that’s what we are doing now). Click browser and navigate to the sdk folder we extracted. This must be the root map you downloaded. The one with folders like tools and platforms in it.

Create an Android app.

Now that we have everything ready to go, it’s time to see if everything is set up correctly and create our first Android app.

  1. In your menu, select: File > New > Project.
  2. In the dialog that should pop up, select Android Project and hit Next.
  3. Now we can set some parameters for our new project. Give a name (“HelloAndroid” for example).
  4. Choose a build-target. Unless you have some specific needs, you should choose the lowest version possible. We’ll go for 1.1.
  5. Give an application name. This is the human readable name for your app.
  6. Give a package for your source to go. I’ll go for be.dimitrivanheucke.blog.android.helloandroid.
  7. Make sure Create an activity is checked. This will create a Class for us that is our main starting point. Call it HelloAndroid
  8. Your dialog box should now look something like this;
    newandroidproject
  9. Hit Finish and ADT will create your project

Testing your application

Before we can test our application, we need to create an AVD (Android Virtual Device). This will be used to present our application in the emulator.

  1. Open your terminal and go to the tools folder inside your downloaded SDK folder.
  2. To create an AVD we need to specify a target. To get a list of targets type;
    ./android list targets
    

    The outcome should look like this;

    Available Android targets:
    id: 1
         Name: Android 1.1
         Type: Platform
         API level: 2
         Skins: HVGA (default), HVGA-L, HVGA-P, QVGA-L, QVGA-P
    id: 2
         Name: Android 1.5
         Type: Platform
         API level: 3
         Skins: HVGA (default), HVGA-L, HVGA-P, QVGA-L, QVGA-P
    id: 3
         Name: Google APIs
         Type: Add-On
         Vendor: Google Inc.
         Description: Android + Google APIs
         Based on Android 1.5 (API level 3)
         Libraries:
          * com.google.android.maps (maps.jar)
              API for Google Maps
         Skins: HVGA (default), HVGA-L, QVGA-P, HVGA-P, QVGA-L
    
  3. Now we can actually create our AVD. Type;
    ./android create avd --name myavd --target 3
    

    Of course you can change the name (myavd) in whatever you like. I used target 3 so we can use this AVD for other projects as well (for example when we integrate Google Maps).
    So we will have a 1.5 OS on our virtual device but we can run any application that targets that sdk version or lower.
    We are done with terminal now, so we can go back to Eclipse.

  4. If, like me, you get some errors on your console panel at the bottom of the window looking like this;

    [2009-08-12 15:02:57 - HelloAndroid] no classfiles specified
    [2009-08-12 15:02:57 - HelloAndroid] Conversion to Dalvik format failed with error 1
    

    You should go to the properties of your project (right mouse click on the project > properties), go to java build path and make sure Android 1.1 is checked in the Order and Export tab.

  5. Now we are ready to test or application! Hit the run button run in the toolbar at the top of your window and select Android Application in the Run As dialog that pops up. After clicking Ok your emulator should load and open your application. This can take a while, your emulator first has to install your application. You might have to unlock the screen first by clicking on the menu button at the bottom of your (android) screen.

emulator

That’s all for setting up your environment and run a first test project.
I’m planning on doing some more of these but haven’t decided on the topics yet. So if you want to see something in particular, let me know in the comments. For the next one I was thinking about integrating Google Maps.

Leave a Reply 42248 views, 17 so far today |
Follow Discussion

One Response to “Getting ready for Android development”

  1. loi duflot Says:

    I beloved up to you’ll receive performed proper here. The caricature is tasteful, your authored subject matter stylish. nevertheless, you command get got an shakiness over that you wish be delivering the following. in poor health indisputably come further formerly again since exactly the similar just about a lot incessantly inside case you shield this increase.

Leave a Reply

*

-->