SDK Tools 24.3.4 (GNU/Linux, Windows)

Principle of operation

The Android SDK contains the SDK Tools, which are built from a different source tree than the SDK.

Recreate matching build environment

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

Build dependencies

# JDK v6
apt-get -y install openjdk-6-jdk xz-utils

# Compiles 32-bit C++ programs
# 'emugen' compiled and run as 32-bit
apt-get -y install make binutils patch
apt-get -y install g++-multilib
apt-get -y install zip unzip libxml2-utils  # zip/unzip/zip + xmllint

# Windows build
apt-get -y remove wine  # running testsuite through wine in both 32- and 64-bit is buggy
apt-get -y install pkg-config  # qemu-android for windows
apt-get -y install autoconf automake1.11  # fix warnings

Locating the source

According to the https://sites.google.com/a/android.com/tools/build/#TOC-Building-the-Linux-and-MacOS-SDK, studio-1.3-release is the current stable version.

studio-1.4-release is actually older than studio-1.3-release, and is probably not published from the internal Android repos as of 2015-09.

Preparing the source tree

Install repo:

sudo apt-get install curl ca-certificates git python
mkdir ~/bin/
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo

# avoid prompts
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
git config --global color.ui true

Checkout the source:

~/bin/repo init -u https://android.googlesource.com/platform/manifest -b studio-1.3-release
# version == 24.3.4 according to 'cd sdk/ && git log' ("Update version from 24.3.3 -> 24.3.4")
#                            and 'sdk/files/tools_source.properties'
~/bin/repo sync
# 15mn with good connectivity
# 15GB (inc. 7GB .repo)

Building SDK Tools

# Use JDK6 (not JDK7)
PATH=/usr/lib/jvm/java-1.6.0-openjdk-amd64/bin:$PATH

mkdir -p out/dist
time bash -x tools/buildSrc/servers/build_tools.sh `pwd`/out `pwd`/out/dist 0  # doesn't accept 24.3.4 as last argument :/
# Note: if needed for speed-up: remove target 'makeWinSdk' in that script
# 25mn, 20GB (inc. 7GB .repo), no ccache

This results in:

  • out/dist/sdk-repo-linux-tools-0.zip
  • out/dist/sdk-repo-windows-tools-0.zip - smaller (178MB vs. 296MB), because the GNU/Linux build has both lib/ and lib64/, and a larger gles_mesa/

We just compiled Tools > Android SDK Tools 24.3.4!

TODO

prebuilts

The build system uses its own:

  • ~/wd/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.8/bin/x86_64-linux-gcc
  • ~/wd/prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/bin/x86_64-w64-mingw32-gcc

at first - cf. external/qemu/android/scripts/gen-android-sdk-toolchain.sh

But it still requires compilers and tools from distro. Note: maybe one should export CC=.../prebuits/...

prebuilts/android-emulator-build/mesa/* are directly copied in the resulting archive.

Error messages and resolutions

  • /home/android/wd/external/qemu/android/scripts/build-qemu-android-deps.sh: 272: [: glib: unexpected operator

    ⇒ Use bash as default shell (see above)

  • warnings/ignored errors in build-qemu-android-deps.sh; about autoheader, pkg-config, automake-1.11, aclocal-1.11, all during the windows part:

    apt-get install autoconf automake1.11

  • 32-bit errors:

    make: /home/android/wd/out/build/emulator/build/default/emugen: Command not found
    /home/android/wd/out/build/emulator/build/default/emugen: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
    

    ⇒ Missing system 32-bit runtime, apt-get install g++-multilib # including the lib32stdc++6 runtime

  • Missing base C files:

    /home/android/wd/sdk/emulator/mksdcard/src/source/mksdcard.c:33:18: fatal error: time.h: No such file or directory
     #include <time.h>
    In file included from /usr/include/time.h:27:0,
    from /home/android/wd/sdk/emulator/mksdcard/src/source/mksdcard.c:33:
    /usr/include/features.h:374:25: fatal error: sys/cdefs.h: No such file or directory
    

    apt-get install g++-multilib # libc6-dev-i386