This page describes the build process of various Android development tools. It is intended to serve as a reference to create Debian specific rules.

Some general android build system info

Android currently (as of 6.0) uses a GNU make based build system. The majority of it's code lives in the build repo, with per-module rules included in their specific repositories (or multiple, as we'll see later)
To get a gist of how a specific Android components is built, an easy way is to run make showcommands <target>, where target is something like 'aapt'. This shows every command used to build that particular target, so it can be logged and replicated for a Debian build.
It is best to use the same android branch as the debian version, and to use releases in general. The Android master branch is something which moves fast, and as of now (6.0) it has a new, faster build system.

NDEBUG

Don't forget to define NDEBUG for C/C++ projects. It is set system wide for Android builds, and not setting it can lead to subtle bugs, such as when asserts are hit.
More info: #827216 #827264
Example: git commit

android.jar

This file contains the public API of the android framework, used when compiling apps. Since it only contains the public parts from the source which also includes private APIs, it's build process is a bit complex.

  1. doclava processes the public parts of the API and puts the relevant files in a folder.

  2. framework-res.apk is built from framework/base/core/res, which includes all the common image and string resources.

  3. Both of the above are then used to create an android.jar including only the public API.

make showcommands api-stubs-docs output from Android 6.0: http://sprunge.us/QOgR

framework-res.apk

doclava

Used to build the SDK docs, and also generate public API stubs for android.jar.
Upstream: https://code.google.com/archive/p/doclava/
Android fork's changes: https://android.googlesource.com/platform/external/doclava/+/android-6.0.1_r43/android-changes.txt
Built with gradle

sources.zip

It includes all the sources used to build android.jar, i.e. the public API of the android framework. Created by a python script

platform.zip

Built using the files defined in development/build/sdk.atree