www.rodneybeede.com "I would love to change the world, but they won't give me the source code" - unknown

How to build an Android ROM from source - Last Modified 2011-10-31 21:48 UTC - Created 2011-10-21 21:46 UTC

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

What I used:

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 http://source.android.com/source/initializing.html
    • 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 https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/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 https://android.googlesource.com/platform/manifest
    • You did remeber to set your path, right?
    • For a different branch: repo init -u https://android.googlesource.com/platform/manifest -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/envsetup.sh
  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 source.android.com


Todo, writeup

todo, more