To complete our tour of the Android Source Tree, we will examine three crucial directories that provide the runtime environment, integrate massive third-party projects, and manage the boot and recovery phases of the OS.
The art/ Directory (Android Runtime)
As discussed in earlier modules, ART is the highly optimized execution engine that runs all Java and Kotlin applications. The source code for this massive, complex virtual machine lives entirely in the art/ directory.
- The Compiler (
dex2oat): Contains the Ahead-of-Time (AOT) and Just-In-Time (JIT) compilers that translate Dalvik bytecode (.dexfiles) into native machine code optimized for the specific CPU architecture of the device. - The Garbage Collector: The highly tuned memory management system that reclaims unused RAM without causing noticeable stutter or frame drops in the user interface.
- The Core Libraries: The underlying C++ implementations of fundamental Java concepts (like Threads, Strings, and Exceptions).
Modifying ART requires extreme caution and deep expertise in compiler theory, as a single bug in memory allocation can instantly crash every single application on the device simultaneously.
# You can force the ART compiler to manually compile an app via ADB
adb shell cmd package compile -m speed -f com.example.myapp
The external/ Directory
Android does not reinvent the wheel. The AOSP platform relies heavily on hundreds of massive, established open-source projects maintained by the broader software community. Google imports these projects into the external/ directory.
Examples of massive external dependencies include:
external/sqlite: The standard relational database engine used by every Android app.external/chromium-webview: The complex rendering engine used whenever an app displays a web page inside itself.external/boringssl: Google's highly secure fork of OpenSSL, handling all cryptographic and secure web connections (HTTPS).external/zlib: The universal library used for data compression and decompression.
When Google imports a project into external/, they add Android.bp build files so the AOSP build system knows exactly how to compile the external C/C++ code seamlessly alongside the native Android OS code.
The bootable/ Directory
This directory contains code that runs before the main Android operating system is fully loaded into memory.
bootable/recovery: The source code for the Android Recovery Mode environment. When you perform a factory reset or install an OTA update, the system reboots into the minimalist Linux environment built from this folder to perform the wiping and flashing operations safely.- Legacy Bootloaders: Historically, this directory also contained open-source bootloader reference implementations (like
lkor Little Kernel). In modern Android development, bootloaders are highly proprietary, heavily secured, and are maintained entirely by the silicon vendors (like Qualcomm) outside of the AOSP tree.