As
promised my how-to for building Android 2.3.4 on Ubuntu 11.04 (64 bit).
I found out that building Android changed a bit since Ubuntu 11.04 and
the documentation on the Android source site isn't up to date. This is
why i choose to write down the steps i did to build Android 2.3.4. So,
go grab yourself a Red Bull and let's get ready to rumble!
What do you need?
Ubuntu 11.04 (64 bit), a internet connection & if your building for a phone.. The phone.
Preparing Ubuntu:
Fire up a terminal, and download the following packages to start with:
sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev libc6-dev g++-multilib lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev libgl1-mesa-dev
Now make sure your using the right version of Java:
sudo add-apt-repository "deb http://archive.canonical.com/ maverick partner"
sudo add-apt-repository "deb-src http://archive.canonical.com/ubuntu maverick partner"
sudo apt-get update
sudo apt-get install sun-java6-jdk
You just downloaded all the software needed to build Android.
Make
sure that your Ubuntu machine can use your USB devices by creating
/etc/udev/rules.d/51-android.rules (as root user) paste the following
inside that file:
# adb protocol on passion (Nexus One)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e12", MODE="0600", OWNER="<username>"
# fastboot protocol on passion (Nexus One)
SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", ATTR{idProduct}=="0fff", MODE="0600", OWNER="<username>"
# adb protocol on crespo (Nexus S)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e22", MODE="0600", OWNER="<username>"
# fastboot protocol on crespo (Nexus S)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e20", MODE="0600", OWNER="<username>"
Please make sure to switch "<username>" to the username of your Ubuntu user.
Now it's time to download the repo and stuff like that. In the same terminal type:
mkdir ~/bin
curl http://android.git.kernel.org/repo > ~/bin/rep
Now open up your bashrc (nano ~/.bashrc) and add the following to the end:
PATH=$PATH:$HOME/bin
Save the file and source it:
source ~/.bashrc
Getting the source:
Now,
make a directory where you would like to build Android. I always keep
my system clean so i made a Android/source/Gingerbread folder:
mkdir -p ~/Android/source/Gingerbread
Now go to that directory:
cd ~/Android/source/Gingerbread
Now let the repository initialize:
repo init -u git://android.git.kernel.org/platform/manifest.git -b gingerbread
android.git.kernel.org 가 막혀 있다면 아래 사이트를 이용하면 된다.
repo init -u https://android.googlesource.com/platform/manifest -b gingerbread
And next sync it. This will take a while :
repo sync
You now have the source code of Gingerbread on your Ubuntu machine. Sweet! Of course, you still have to build it.
Building the source:
First i will explain how to build a normal generic build. This is a non phone specific build. In the Android source folder type:
. build/envsetup.sh
This
will prepare your build environment. This is needed to have tools like
lunch, mmm and other nifty Android specific tools. Now it's time
to actually choose our version of 2.3.4:
lunch
You
will be asked which Android version you want, choose "generic". Now!
It's time for the real deal, building the source. It's time to fire up
make:
make -j4
Do
note that there are diffrent -j parameters of make to build faster. You
could use make -j4 if you have 2 cores, and make -j8 if you have 4.
This will speed up the building.
If the building ends with
something like system.img that the build went ok. Congratulations you've
just build Android 2.3.4. You can flash it to your phone with fastboot.
But this is just a generic build missing device specific features.
Building the source for the Nexus One:
Connect
your phone to your PC, and make sure that it's on debugging mode. From
the root of your source, go to the Passion (code name for Nexus One)
specific folder:
cd device/htc/passion
Import all the needed files:
./extract-files.sh
If
this ends with no errors your done, you can now return to the root of
your source tree. If you followed this how to go back to:
~/Android/source/Gingerbread
Now use lunch to choose the passion-full-userdebug build.
lunch
And! Now you can use make to build Android:
make -j4
If your build ends with something like this:
Install system fs image: out/target/product/passion/system.img
The
build is complete. You can again use fastboot to flash it to your
device. You now have the full open source version of Android running on
your phone.
If you have any questions about this topic please
don't hesitate to ask them in the comments i'll do my best to give
answers when possible.