How to build an Android ROM from source

Last Modified: Mon, 31 Oct 2011 21:48:45 +0000 ; Created: Fri, 21 Oct 2011 21:46:26 +0000

You can find many useful details on Google's official site at They have updated a lot if it recently and those steps are basically all the ones I used.

What I used:

  • Ubuntu Server 11.04 AMD64
  • Installed onto ProxMox VM
    • Fully Virtualized (KVM)
    • 8 CPU sockets, 1 core / socket
    • 4GiB memory
    • 160GB SCSI disk
    • 2 NICs, one internal VLAN, one Internet VLAN (external router with NAT)
    • CD-ROM pointing to ISO for installer

OS Setup

  1. Installed Ubuntu
  2. Created "android" user
    • Has sudo access
    • SSH public key login
    • Used for building, could be anything really
  3. Setup Internet connectivity
  4. sudo apt-get update
  5. sudo apt-get upgrade
  6. sudo /sbin/reboot
  7. uname -a
    • Mine shows "Linux linux-android-64bit 2.6.38-8-server #42-Ubuntu SMP Mon Apr 11 03:49:04 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux"

Compiler Tools

  1. sudo apt-get install gcc g++ gcc-multilib g++-multilib
  2. gcc --version
    • gcc (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2
  3. g++ --version
    • g++ (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2
  4. perl --version
    • This is perl, v5.10.1 (*) built for x86_64-linux-gnu-thread-multi

Android Build Tools and Environment

  1. Just use the command from "Installing required packages" at
    • sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils
  2. mkdir ~/bin
  3. PATH=~/bin:$PATH
    • You may wish to place this in your ~/.bashrc or other startup script
  4. curl > ~/bin/repo
  5. chmod a+x ~/bin/repo
  6. sudo apt-get install default-jdk
  7. python --version
    • Python 2.7.1+

Android Source

  3. repo init -u
    • You did remeber to set your path, right?
    • For a different branch: repo init -u -b android-2.3.7_r1
  4. repo sync
    • "The initial sync operation will take an hour or more to complete" when pulling down master


  2. source build/
  3. lunch full-eng
    • For building emulator rom, see Android source site
  4. make -j8


This is for running on an emulator. See later sections for other devices.
  1. make -j8 sdk
  2. Copy the system.img, ramdisk.img, and userdata.img files in ~/ANDROID_WORKING_DIRECTORY/out/target/product/generic to a machine with a GUI and the Android SDK installed
  3. On the machine with the Android SDK run the emulator with
    • android-sdk-windows\tools\emulator -system system.img -ramdisk ramdisk.img -data userdata.img
    • Update the paths accordingly
  4. Optionally if the machine you are building on has a GUI you can just run "emulator" and by default it will load the latest build images for you

Building for specific hardware device

For run instructions on how to flash and run see Run It on


Todo, writeup

todo, more