AOSP Build

How to build AOSP

It’s a quick & short recipe to build the Android source code.

The first step to working on AOSP is to set it up and get it ready to develop. Let’s see what steps are needed:

  • Download the Android source code
    • Install repo in the target machine which usually is a Linux distro. ( I always use Ubuntu)
sudo apt-get install repo
  • Create a directory on disk and init the repo.
    • Run repo sync to download the source code
mkdir aosp  & cd aosp
repo init -u
  • Install essential packages to build AOSP
    • There’re a couple of essential packages that should be installed to make it possible to build AOSP
sudo apt-get install git-core gnupg flex bison build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 libncurses5 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev libxml2-utils xsltproc unzip fontconfig
  • There’s another option to use a docker image containing all required packages which usually is the best option, since you won’t face any conflict between installed packages on the machine and the new ones. Follow the link below to download and run the docker image:

  • Set up environment
source build/
  • Select the target variant
  • Build it

If you don’t have 32GB RAM, it’s better to reduce the threads running to build. For example:

make -j4

You can find a complete reference on the Google website.

Leave a Comment

Your email address will not be published. Required fields are marked *