2010.10.16

How to Install Android on Ubuntu Linux

android.png

Once again I've decided that I want to take a look at programming for the Android platform. One of the first things to do is to get an Android emulator and a programming environment setup. After searching around a few different sites to get the instructions I've compiled the steps to get an emulator working under Ubuntu Linux here.

Android SDK Manager

I followed the steps on the android site. Using the command line in Ubuntu, here are the steps to follow:

Install OpenJDK:

sudo apt-get install openjdk-6-jre

If you are running a 64-bit OS, then install the needed 32-bit libs:

sudo apt-get install ia32-libs

Download the latest SDK from the Android site (which, as I write this, is android-sdk_r07-linux_x86.tgz).

Uncompress the tarball into your home directory and rename it:

tar xfvz android-sdk_r07-linux_x86.tgz
mv android-sdk-linux_x86 android-sdk

Here are all of the above steps combined:

sudo apt-get -y install openjdk-6-jre
uname -m | grep -q "\(x86_64\|ia64\)" && sudo apt-get -y install ia32-libs
cd
wget http://dl.google.com/android/android-sdk_r07-linux_x86.tgz
tar xfvz android-sdk_r07-linux_x86.tgz
[ -e android-sdk ] && mv android-sdk android-sdk.$(date +%y%m%d)
mv android-sdk-linux_x86 android-sdk

Optionally you may add the Android tools directories to your PATH by adding the following to your .bashrc file:

export PATH=${PATH}:${HOME}/android-sdk/tools:${HOME}/android-sdk/platform-tools

Now run the Android SDK and AVD Manager via:

~/android-sdk/tools/android

Or, if you are running GNOME, make a custom application launcher, by either right-clicking a panel and selecting Add to panel… then adding a Custom Application Launcher, or by right-clicking the Main Menu and selecting Edit Menus then select Programming then New Item. The custom application launcher should have the following properties (substitute your $HOME directory for /home/USERNAME):

  • Type: Application
  • Name: Android SDK Manager
  • Command: /home/USERNAME/android-sdk/tools/android
  • Icon: gnome-robots.png

Now configure the Android Manager:

  • Click on Settings, then check Force https://… sources to be fetched using http://
  • Click on Installed Packages, then Update All…, then Accept All followed by Install on the window that comes up; it will take a while to download and install everything; when it finishes, close the window (and the application if prompted to do so)
  • Redo the above step until no more updates can be performed
  • Click on Virtual Devices, then New…, give it a Name and select a version of Android for Target, then optionally add an SD Card and Hardware as desired, finally click Create AVD

You can now run this virtual android image by clicking the Start… button. Or from the command line (replacing NAME with the name of the virtual you created):

~/android-sdk/tools/emulator @NAME

You can also create a custom application launcher with that command.

The next time you want to make sure your android installation is updated you can run:

~/android-sdk/tools/android update sdk

#+BEGIN_COMMENT

Android on VirtualBox

I followed the steps this article. Using the command line in Ubuntu, here are the steps to follow:

First, if you do not already have VirtualBox installed, you can install the open source edition with the following command:

sudo apt-get install virtualbox-ose

Now, under your Accessories menu you should see the VirtualBox OSE launcher.

#+END_COMMENT

Eclipse IDE

Even though I prefer to code in Emacs whenever possible, the recommended method of programming for the Android platform is with the Eclipse IDE. So, I'm starting with that at least until I get more used to Android programming.

At first I tried to install Eclipse with apt-get like so:

sudo apt-get install eclipse

However, I could not get the Android Development Tools to install with that version of Eclipse (Galileo v3.5.2). So, like many others have, I decided to use the latest version from their web site. I downloaded the 64-bit Eclipse Classic (Helios v3.6.1) tarball from their download page. You should download the correct version for your architecture and uncompress it in your home directory.

tar zxvf eclipse-SDK-3.6.1-linux-gtk-x86_64.tar.gz

You might want to create a custom application launcher for it with these settings:

  • Type: Application
  • Name: Eclipse
  • Command: /home/USERNAME/eclipse/eclipse
  • Icon: /home/USERNAME/eclipse/icon.xpm

Now launch Eclipse. Then select Install New Software from the Help menu and add the following sites:

Install everything from each of them in the above order.

After that finishes, select Preferences from the Window menu. Select Android on the left and set the SDK Location to /home/USERNAME/android-sdk or wherever you installed the Android SDK. When you apply it you should see a list of Android target versions. OK the change.

Now when you create a new project, you can pick Android as a type.

James DeBragga [Windows Consumer Product Manager]: Android is "free like a puppy".

spark: "Free like a puppy" is certainly much, much better than an atrociously priced and uncontrollably incontinent, rabies-infected mad hound.