My First Android Adventure

Here are my notes about getting the Android SDK up and running using only the command line tools that come in the SDK.

The following worked for me on Ubuntu 10.04 LTS as of September 2011. I find Eclipse to be an excruciating form of torture, so I'm not following the Eclipse-based instructions. Everything below can be done from vi or emacs and the command line.

Installation

  1. Download the SDK.
  2. Unpack the SDK.
  3. Run android-sdk-linux_x86/tools/android to bring up the AVD Manager. (AVD is "Android Virtual Device" -- it will run in the emulator.)
  4. Select "Available Packages", and expand "Android Repository". It will fetch a list of packages.
  5. Select "Android SDK Platform-Tools, Version 7". (You need this.)
  6. Select "SDK Platform Android 2.2, API 8, revision 3". (You need at least one platform. My development phone has Android 2.2, so that's what I'm initially targeting. You can add more platforms later.)
  7. I also selected Documentation and Samples, for convenience.
  8. Install the packages you selected. Restart ADB when prompted.
  9. Then create a new virtual device. In the AVD Manager, click "Virtual Devices", then "New...". Give your device a name, choose the platform, click Create.
  10. Install the ubuntu package "ant1.8". Don't install "ant" -- this is version 1.7, which won't work with the android SDK.

Create a New Project

I unpacked the tools under ~/projects/android.

From that directory, I can give this command:

./android-sdk-linux_x86/tools/android create project \
  -p ./hello_android -t android-8 -a HelloAndroid \
  -k "com.blakitasoftware.hello_android"

This creates ~/projects/android/hello_android/ containing the new project.

Build the Project

Change into the hello_android directory. Run ant debug.

(Read this for info on package signing and building in debug mode.)

Run the Application

Since we built in debug mode, we don't need to worry about signing -- we can run it in the emulator right away.

First start the virtual device: run android with no arguments, find your device, click "Start...", "Launch".

Install the application by running (assuming you're still in the hello_android directory):

../android-sdk-linux_x86/platform-tools/adb \
  install ./bin/HelloAndroid-debug.apk

Then go to the emulator, click the Launcher. (This is the grid of little gray squares in the bottom of the screen. Yeah, it took me a few seconds to figure this out -- I've never even used an Android phone, this really is an adventure...) Find your HelloAndroid app, click it, and you'll see the greeting ("Hello World, HelloAndroid").

Make a Change

To change that greeting, edit res/layout/main.xml.

Assuming you only have one emulator running, the build and install sequence given above can be abbreviated to ant install. This reinstalls your app with the new greeting, find your app in the launcher again and rerun it to see the change.

Posted on 2011-09-26 by brian in android .
Comments on this post are closed. If you have something to share, please send me email.