Set Up for AOSP development (1.5 - 8.0)

This document discusses how to set up for development with Android 8.0 or previous versions. To learn how to build Android 9.0 and later, see Set up for AOSP development.

Set Up for AOSP development (5.0 - 8.0)

For Android 5.0 through 8.0, consider using the included Dockerfile to ease the installation of all required packages.

Operating systems

Android is typically built with a GNU Linux. It's also possible to build Android in a virtual machine on unsupported systems such as Mac OS X.

Google recommends building on GNU Linux. The Android build system normally runs ART on the build machine to precompile system DEX files. ART can run only on Linux, so the build system skips this precompilation step on non-Linux operating systems, resulting in an Android build with reduced performance.

GNU Linux

  • Android 5.x (Lollipop): Ubuntu 12.0
  • Android 6.0 (Marshmallow) - AOSP 8.0 (Oreo): Ubuntu 14.04 (Trusty)

Mac OS X (Intel/x86)

  • Android 6.0 (Marshmallow) - AOSP 8.0 (Oreo): Mac OS X v10.10 (Yosemite) or later with Xcode 4.5.2 and Command Line Tools
  • Android 5.x (Lollipop): Mac OS X v10.8 (Mountain Lion) with Xcode 4.5.2 and Command Line Tools

JDK

Set up for AOSP development (1.5 - 4.4)

This section provides some guidance for how to set up Android 1.5 through Android 4.4.

Operating systems

Android is typically built with a GNU Linux. It's also possible to build Android in a virtual machine on unsupported systems such as Windows.

Google recommends building on GNU Linux. The Android build system normally runs ART on the build machine to precompile system DEX files. ART can run only on Linux, so the build system skips this precompilation step on non-Linux operating systems, resulting in an Android build with reduced performance.

GNU Linux

  • Android 2.3.x (Gingerbread) - Android 4.4 (KitKat): Ubuntu 12.0 (Precise)
  • Android 1.5 (Cupcake) - Android 2.2.x (Froyo): Ubuntu 10.04 (Lucid)

Mac OS X (Intel/x86)

  • Android 4.1.x (Jelly Bean) - Android 4.4.x (KitKat): Mac OS X v10.6 (Snow Leopard) or Mac OS X v10.7 (Lion) and Xcode 4.2 (Apple Developer Tools)
  • Android 1.5 (Cupcake) - Android 4.0.x (Ice Cream Sandwich): Mac OS X v10.5 (Leopard) or Mac OS X v10.6 (Snow Leopard) and the Mac OS X v10.5 SDK

GNU make

For versions previous to the AOSP main branch through Android 4.1.x (Jelly Bean), use GNU make (gmake) 3.82. For Android 4.0.x (Ice Cream Sandwich) and lower, revert from gmake 3.82 to avoid build errors.

Xcode and other packages

For Mac OS X v10.8 or lower, install Xcode from the Apple developer site. If you are not already registered as an Apple developer, you must create an Apple ID to download.

If using Mac OS X v10.4, also install Bison:

POSIXLY_CORRECT=1 sudo port install bison

For MacPorts, issue:

POSIXLY_CORRECT=1 sudo port install gmake libsdl git gnupg

For Homebrew, issue:

brew install gmake libsdl git gnupg2

Reverting from gmake 3.82

In Android 4.0.x (Ice Cream Sandwich) and lower, gmake 3.82 has a bug that prevents Android from building. You can install version 3.81 using MacPorts with these steps:

  1. Edit /opt/local/etc/macports/sources.conf and add file:///Users/Shared/dports above the rsync line.

  2. Create the dports directory:

    mkdir /Users/Shared/dports
    
  3. In the new dports directory, run:

    svn co --revision 50980 http://svn.macports.org/repository/macports/trunk/dports/devel/gmake/ devel/gmake/
    
  4. Create a port index for your new local repository:

    portindex /Users/Shared/dports
    
  5. Install the lower version of gmake:

    sudo port install gmake @3.81
    

JDK

  • Android 2.3.x (Gingerbread) - Android 4.4.x (KitKat):

  • Android 1.5 (Cupcake) - Android 2.2.x (Froyo):

JDK for Linux

The Android Open Source Project (AOSP) comes with prebuilt versions of OpenJDK below prebuilts/jdk/ so no additional installation is required.

Earlier versions of Android require a separate installation of the JDK. On Ubuntu, use OpenJD

For Ubuntu 15.04 and higher

Run the following:

sudo apt-get update
sudo apt-get install openjdk-8-jdk

For Ubuntu LTS 14.04

There are no available supported OpenJDK 8 packages for Ubuntu 14.04. The Ubuntu 15.04 OpenJDK 8 packages have been used successfully with Ubuntu 14.04. Higher package versions (for example, those for 15.10, 16.04) don't work on 14.04 using the following instructions.

  1. Download the .deb packages for 64-bit architecture from old-releases.ubuntu.com

    • openjdk-8-jre-headless_8u45-b14-1_amd64.deb with SHA256 0f5aba8db39088283b51e00054813063173a4d8809f70033976f83e214ab56c0
    • openjdk-8-jre_8u45-b14-1_amd64.deb with SHA256 9ef76c4562d39432b69baf6c18f199707c5c56a5b4566847df908b7d74e15849
    • openjdk-8-jdk_8u45-b14-1_amd64.deb with SHA256 6e47215cf6205aa829e6a0a64985075bd29d1f428a4006a80c9db371c2fc3c4c
  2. Optionally, confirm the checksums of the downloaded files against the SHA256 string listed with each package above. For example, with the sha256sum tool:

    sha256sum {downloaded.deb file}
    
  3. Install the packages:

    sudo apt-get update
    
  4. Run dpkg for each of the .deb files you downloaded. It may produce errors due to missing dependencies:

    sudo dpkg -i {downloaded.deb file}
    
  5. To fix missing dependencies:

    sudo apt-get -f install
    

(Optional) Update the default Java version

Optionally, for the previously mentioned Ubuntu versions , update the default Java version by running:

sudo update-alternatives --config java
sudo update-alternatives --config javac