How To Setup Android SDK in Ubuntu

If you pay attention to technology at all, you probably know about Google’s Android platform. People have largely panned it because they were expecting a gPhone to do battle with the iPhone. I think they are missing the point. This is the first time ever where there is a well documented and supported open source mobile platform. I joined the Android developer’s mailing list last night, and I’ve already gotten almost 200 messages on it. Whether or not people are excited, developers are excited about developing mobile applications for this new platform. Some of that excitement might have to do with the cash prizes, but I doubt that’s the only factor.

Anyway, one of my major disappointments with the iPhone is the lack of podcatching software. If it had a podcatcher, I probably would have bought one right off the bat. Android has presented me with the opportunity to write my own mobile podcatching software. I’ve decided that I’m going to go for it. Being an Ubuntu user, I had to setup the SDK to get working. However, I ran into a few problems along the way. Since I suspect many other Ubuntu users out there also might want to get into the Android developing business, here I will post how I got the development environment setup in Ubuntu.

The first thing you need is a computer with Ubuntu 7.10 Gutsy Gibbon installed. The computer should be connected to the Internet. Ubuntu by default tries to use open source versions of Java, and while these are pretty good, they will not work for android development. The fact that Ubuntu will not default to using Sun Java, even after you install it explicitly, is the primary reason this how to is necessary. Anyway, the first step is to update your packages and install Eclipse and Sun Java.

sudo aptitude update
sudo aptitude install eclipse sun-java6-jdk

If you want to use Sun Java as the default JVM in your web browsers, run this command as well.

sudo aptitude install sun-java6-plugin

Now you need to make Sun Java the default jvm in Ubuntu. You can do that with this command.

sudo update-java-alternatives -s java-6-sun

We also need to edit the file /etc/jvm. Edit that file as root with your favorite text editor.

sudo gedit /etc/jvm

The contents of the file will look something like this.

/usr/lib/jvm/java-gcj
/usr/lib/jvm/ia32-java-1.5.0-sun
/usr/lib/jvm/java-1.5.0-sun
/usr

Change it to look like this, then save and quit your text editor.

/usr/lib/jvm/java-6-sun
/usr/lib/jvm/java-gcj
/usr/lib/jvm/ia32-java-1.5.0-sun
/usr/lib/jvm/java-1.5.0-sun
/usr

When certain programs on your system want to run java, they will look at this file to figure out which JVM to use. They will try every JVM in the list starting with the one on top until one of them works. Eclipse, however, does not use this file. It has its own file that works in the same way. First edit the eclipse java_home file as root.

sudo vim /etc/eclipse/java_home

There should already be a line in that file for Sun Java 6. Move this line to the top of the file. Add it to the top if it isn’t there.

/usr/lib/jvm/java-6-sun

Now your Ubuntu system is ready to run the Android development kit. Go to the Android documentation site and follow the directions there. Have fun making mobile apps in Java!

This entry was posted in Technology and tagged , , , , , . Bookmark the permalink.

One Response to How To Setup Android SDK in Ubuntu

  1. Eric says:

    Thanks so much for posting this…I was stuck for so long I started considering IPhone development :P, but this fixed my problem.

Comments are closed.