Building Android 1.5 – Build environment 9

Last year I bought an Android Dev Phone. I wanted to be one of the first to use this great device and operating system. The Android Dev Phone makes it possible to flash it with your own build version of Android. So why not building the Android OS from source?

This first part of Building Android 1.5 is about setting up the build environment. There is a description available at I will write down the steps I have taken to give you a step by step manual

Installation of Ubuntu

I installed Ubuntu as a Virtual Machine (because I am running Windows Vista). I used Ubuntu 8.04 because this is also the environment which Google is using (as I should believe). There are some issues with Ubuntu 8.10 for example when building the source.

I will not explain the installation of Ubuntu. This is really straight forward (perhaps even easier than installing Windows) when putting in the Ubuntu CD and boot from it.

When Ubuntu is installed I did sudo apt-get update and sudo apt-get upgrade to have the latest versions of all the packages which are installed by default

Required packaged

In order to retrieve the source code from git and to build the Android OS, the installation of some packages is required. Install the following packages by executing sudo apt-get install <pakagename>

  • git-core
  • gnupg (this package was already installed)
  • sun-java5-sdk (don’t use java 6 because this will result in errors during build)
  • flex
  • bison
  • gperf
  • libsdl-dev
  • libesd0-dev (the last 0 is a zero)
  • libwxgtk2.6-dev
  • build-essential
  • zip (already installed)
  • curl
  • libncurses5-dev
  • zlib1g-dev
  • valgrind (this packge is optional)

Instead of installing the packages seperately, you can also comine the apt-get install command

sudo apt-get install git-core gnupg sun-java5-jdk flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev valgrind

At is written that Ubuntu 8.10 users should install a newer version of libreadline. I found out that I also needed this package because otherwise repo gives errors.

sudo apt-get install libreadline5-dev

Note: the Get source page on the android website uses a different package name (lib32readline5-dev) but that one does not exists

Java Environment

It could be possible that java 6 is installed on your own Ubuntu installation. To check which Java version is used, run the command

update-java-alternatives -l

In my Ubuntu enviroment only one java version is given back in the result

java-1.5.0-sun 53 /usr/lib/jvm/java-1.5.0-sun

If multiple versions are installed, use update-java-alternatives -s to change the default Java Environment. For example

update-java-alternatives -s java-1.5.0-sun

The location of the Java installation should also be set exported as $JAVA_HOME. Edit the .bashrc file inside your users home directory. Add the following line to the end of the file

export JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun-

The location of the Java installation can be different (depending on the version number which is in my case Check the location first to see if it contains the Java installation.

Start a new terminal and check if $JAVA_HOME is working and pointing to the right location


When the result given back is correct (for example /usr/lib/jvm/java-1.5.0-sun. the $JAVA_HOME is correctly set.

You can also check if the correct Java version is used by running the command java -version

java -version


java version "1.5.0_16"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b02)
Java HotSpot(TM) Client VM (build 1.5.0_16-b02, mixed mode, sharing)

What’s next?

By installing Ubuntu, de required packages and setting up Java everyting is ready for downloading the source from Git and building your own version of the Android source. I will explain the steps of retrieving the source code from Git in a next blog item.  Feel free to give feedback on this post.

Blogpost in the Building Android 1.5 serie

9 thoughts on “Building Android 1.5 – Build environment

  1. Pingback: The Open Mob for Android(TM): Faq Dream Build

  2. Reply Munvar Jun 19, 2009 10:43 am

    thanks for your knowledge sharing

  3. Pingback: Building Android 1.5 – Google Apps and audio files « Johan de Koning

  4. Pingback: Building Android 1.5 – Flashing the phone « Johan de Koning

  5. Pingback: Building Android 1.5 – Getting the source « Johan de Koning

  6. Pingback: Building Android 1.5 – Building the source « Johan de Koning

  7. Pingback: Baking a Donut for a Dream « Things about stuff

  8. Reply lichsword Mar 15, 2010 7:27 am

    thanks for your share

  9. Reply winston Mar 19, 2010 3:10 am

    thanks for sharing~~~and i want to know how to build the rom of G2?

Leave a Reply