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 http://source.android.com/download. 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
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>
- gnupg (this package was already installed)
- sun-java5-sdk (don’t use java 6 because this will result in errors during build)
- libesd0-dev (the last 0 is a zero)
- zip (already installed)
- 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 http://source.android.com/download 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
It could be possible that java 6 is installed on your own Ubuntu installation. To check which Java version is used, run the command
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
The location of the Java installation can be different (depending on the version number which is in my case 18.104.22.168). 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.22.214.171.124) 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 "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)
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