SDK 9.0.0r21 (GNU/Linux, Windows)

Recreate matching build environment

The current reference build environment for this version is Ubuntu 14.04.

Build dependencies

dpkg --add-architecture i386
apt-get update

apt-get -y install wget
cat <<'EOF' > $checksumfile
0f5aba8db39088283b51e00054813063173a4d8809f70033976f83e214ab56c0  openjdk-8-jre-headless_8u45-b14-1_amd64.deb
SHA256 9ef76c4562d39432b69baf6c18f199707c5c56a5b4566847df908b7d74e15849  openjdk-8-jre_8u45-b14-1_amd64.deb
SHA256 6e47215cf6205aa829e6a0a64985075bd29d1f428a4006a80c9db371c2fc3c4c  openjdk-8-jdk_8u45-b14-1_amd64.deb
sha256sum $checksumfile || exit "Incorrect checksums"
dpkg -i openjdk-8-jdk_8u45-b14-1_amd64.deb \
  openjdk-8-jre-headless_8u45-b14-1_amd64.deb \
  openjdk-8-jre_8u45-b14-1_amd64.deb || true
apt-get -y -f install

apt-get -y install git-core gnupg flex bison gperf build-essential zip \
  curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 \
  lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev \
  libgl1-mesa-dev libxml2-utils xsltproc unzip

# TODO: are hose still necessary?
apt-get -y install python-networkx
apt-get -y install zlib1g-dev:i386

# Windows dependencies
#  2015-07-23
apt-get -y install mingw32 tofrodos

Prepare source tree

Install repo:

sudo apt-get install curl ca-certificates git python
mkdir ~/bin/
curl > ~/bin/repo
chmod a+x ~/bin/repo

# avoid prompts
git config --global ""
git config --global "Your Name"
git config --global color.ui true

Checkout the source:

mkdir ~/wd/
cd ~/wd/
~/bin/repo init -u -b android-9.0.0_r21
time ~/bin/repo sync --current-branch -j4
# 1h15 with fiber connection
# 32GB .repo

Build the SDK

# Optional: reserve 10GB for ccache if you're investigating how to build or patching something
# Cf.
#export USE_CCACHE=1
#prebuilts/misc/linux-x86/ccache/ccache -M 10G

export BUILD_NUMBER="user.9.0.0_r21"
. build/
lunch sdk-user
time make sdk -j$(nproc) showcommands dist

time make win_sdk -j$(nproc) showcommands dist


-rw-r--r-- 1 android android 729M Dec  7 23:30 out/dist/
-rw-r--r-- 1 android android 731M Dec  7 23:32 out/dist/
-rw-r--r-- 1 android android 729M Dec  7 23:30 out/host/linux-x86/sdk/sdk/
-rw-r--r-- 1 android android 731M Dec  7 23:32 out/host/windows/sdk/sdk/


Rebuild the prebuilts/ sub-directories.

win_sdk shouldn't rebuild/repack the linux SDK.

Error messages and resolutions

Prepare a LOT of disk space.


Build result recap

$ tools/bin/sdkmanager --list
Installed packages:
  Path                                         | Version    | Description                       | Location                            
  -------                                      | -------    | -------                           | -------                             
  build-tools;28.0.1                           | 28.0.1     | Android SDK Build-Tools 28.0.1    | build-tools/android-9/              
  docs                                         | 1          | Documentation for Android SDK     | docs/                               
  platform-tools                               | 28.0.0 rc1 | Android SDK Platform-Tools 28 rc1 | platform-tools/                     
  platforms;android-28                         | 5          | Android SDK Platform 28, rev 5    | platforms/android-9/                
  system-images;android-28;default;armeabi-v7a | 3          | ARM EABI v7a System Image         | system-images/android-9/armeabi-v7a/

Using SDK Tools:

  tools                                        | 26.1.1     | Android SDK Tools 26.1.1          | tools/                         

ccache usage


build stats

Using i5-6300HQ (4x2.30GHz), SSD disk:

  • make sdk: build completed successfully (03:17:40 (hh:mm:ss))
  • make win_sdk: build completed successfully (02:15:22 (hh:mm:ss))
  • du -sh wd/: 205G
  • du -sh wd/.repo/: 33G

Automated build recipe