Build an Android app in 15 minutes or less
Christian Karasiewicz 270005XS4E Comments (3) Visits (11993)
This blog post contributed by Owen Cline, a member of the IBM Software Services for Websphere team based in San Diego, California.
So you want to build an Android app but you think it will be too hard, right? Well, think again!
What will you need?
The first thing that you will need to do is set up your development environment. Fortunately, there is no cost to do this, and it is easy to install. Normally, you will need three things:
Luckily, all of the required tools have been integrated together into the ADT (Android Developer Tools) Bundle.
Install the Android Bundle
The Android Bundle is downloaded as a ZIP file. All you need to do is unpack the ZIP file (named adt-
Open your Android Bundle directory, in my case:
You will see SDK Manager.exe. The Android SDK separates tools, platforms and other components into packages you can download using the SDK Manager. You don't have to modify the Android SDK now. I just wanted to point out what the SDK Manager is and show it to you:
Start up Eclipse
Now, open your Android Bundle Eclipse directory. My directory is:
Now you can start the Eclipse.exe. When Eclipse first runs, it will prompt you for a directory to create a workspace. An Eclipse workspace is a directory where Eclipse will store all of your source code files. My workspace directory is:
Create an Android Project
When Eclipse opens, you can now create your Android Project. Basically, you need to do the following steps:
You can refer to this blog post, which goes through the screen captures for an Android application project creation: “Writing your first Android application in five minutes.” Once the project is created, we will build and test the application.
Build a user interface
Let's work on the application. In my case, I named my Android application project "My First App." The first thing I want to do is create a user interface. In particular, I will add an analog clock. I need to open the "layout" directory, which is under the "res" directory in my project. You can navigate to that directory inside the Eclipse Package Explorer:
Next, I need to double click on the "activity_main.xml" file to open it. It is in this file that we can modify the user interface. The visual editor will open:
Let's create a user interface with one text control and one button.
To add a text control, click on "Text Fields" in the palette. Then drag the top text control on to your user interface:
Next , let's add a button control. Click on the "Form Widgets" in the palette. Then drag the button control on to your user interface:
Notice that there are two tabs at the bottom of the editor called "Graphical Layout" and "act
Run the Android application
That is enough development of the application for now. Now we want to run the Android application in an Android emulator that is built in to the Android SDK.
To do this, try these steps:
The first dialog you will see is:
You are getting this because you have not set up a target Android Application emulator yet. The Android SDK supports many flavors of Android devices, and you have to select one as your emulator.
Click on "Yes" to continue.
Next you see the “Android Device Chooser” dialog:
Select the "Launch a new Android Virtual Device" radio button. Then click on the "Manager" button.
The “Android Virtual Device Manager” dialog will appear. Click on the "New" button:
You will next see the "Create a new Android Virtual Device (AVD)" dialog. You need to enter an AVD name, a device and a target:
Next , click the "OK" button.
You can close the “Android Virtual Device Manager” dialog now.
Back in the "Android Device Chooser" dialog, click on the "Refresh" button and select the Android Virtual Device that you just created. Now, click on the "OK" button.
The Android Virtual Device emulator should start:
Back in the "Android Virtual Device Manager" dialog, click on the "Refresh" button and you should see your AVD defined with a green check mark:
You can close the "Android Virtual Device Manager" dialog.
Now that an Android Virtual Device has been created, you need to go through the steps that were discussed earlier to run your application as an Android application.
As a reminder, repeat these steps:
You can trace the steps used to deploy your Android application in the emulator:
You should first see your Android application listed on the emulator's screen, "My First App":
Click on your Android application icon to launch it:
That's all there is to it. You wrote, deployed and tested your first Android app. Good for you!
If you have questions, please contact me on Twitter.