Tuesday, May 18, 2010

Installing Android development tools

Previous: Installing Oracle Express and ADF - FAIL!

Because Android development is supported by a special Eclipse plugin, I wanted to run a separate instance of Eclipse configured for Android development. I downloaded the basic (non JEE) version of Eclipse from http://www.eclipse.org/ unpacked it into my home directory using
tar xzvf eclip*
and renamed the resulting eclipse directory to .eclipse-android.

Next, I followed the instructions at http://developer.android.com/sdk/installing.html#Installing to install the Android SDK starter package. After downloading the package (in this case, the 64-bit Linux version), I unpacked it into my home directory with
tar xzvf android-sdk*
and renamed the resulting directory from android-sdk-linux_86 to .android-sdk.

The instructions suggest adding the tools subdirectory to PATH in .bash_profile or .bashrc. Because of the way I've got my startup files organized at the moment I'm setting PATH in .profile, so I defined it there by adding the line,
PATH=$PATH:~/.android-sdk/tools
Then I followed the instructions at http://developer.android.com/sdk/eclipse-adt.html to install the Android Development Tools (ADT) plugin for Eclipse.

I started Eclipse and created the workspace android-sandbox when prompted. Then I went to Help > Install New Software > Add... and entered this URL into the Location field:
https://dl-ssl.google.com/android/eclipse/
It seemed to take longer than these things usually take, but eventually Developer Tools appeared in the list of available software. Android DDMS and Android Development Tools came up, as per the instructions. I clicked Next, accepted the license agreement, and clicked Finish. After a fairly lengthy download process and a warning about installing unsigned content, the plugins seemed to install. When Eclipse restarted, I found Android Project and Android Test Project listed under New... > Other.... So far, so good.

Next, I told Eclipse where to find the Android SDK. In Window > Preferences > Android, I browsed to the .android-sdk directory and set that as the SDK location.

In a Terminal window, I started the ddms utility, went to File > Preferences... > Usage Stats and unchecked the checkbox for sending usage statistics to Google.

The instructions say you should use the "Android SDK and AVD Manager" to download at least one platform and any additional components you want. The real name of the program is android. I determined that by starting each of the executables in the tools directory one by one. Fortunately, android was only the second one in the alphabetical list! (Note: Later I noticed that Android SDK and AVD Manager is an option on Eclipse's Window menu.)

I chose Available Packages and the program populated the list. Being new to this, I wasn't too sure what I needed. I chose the documentation as well as the platform and API for Android 1.5, API 3, revision 3, and the samples. I clicked Install Selected, accepted the license agreement, and clicked Install. This started an insanely long download. I went to bed and let it run overnight.

The next morning I browsed through the SDK directory tree to see what had been installed. Then I followed the "Hello World" tutorial at http://developer.android.com/resources/tutorials/hello-world.html. The tutorial covers some of the basic setup you have to know about in order to develop Android apps, so I suggest following it if you're doing this for the first time. The tutorial assumes you're using Eclipse for development. If you're using a different development environment you'll have to work out how to take the equivalent setup steps.

The tutorial instructions were accurate and everything worked as documented.

There doesn't appear to be much documentation about TDD for Android apps, but there is some sample test code in the ApiDemo sample app. I think my next step in learning about Android development will be to work out a good way to do TDD, with this example as a starting point.

Next: sudo:must be setuid root

No comments:

Post a Comment