Android.bp and Android.mk Files
Build system files in AOSP - what they do and how to use them
1 min readWhen you build an AOSP module - whether it's a library, an app, or a HAL - you need a build file that tells the build system what to compile, what to link against, and where to install the output. AOSP has two such systems: the older Make-based system (Android.mk) and the newer Soong system (Android.bp).
Android.mk - The Old Make System
Android.mk files use GNU Make syntax. They were the only build system in AOSP for many years. While still supported, they are being phased out because Make is slow, hard to parallelize, and difficult to reason about for large codebases.
Android.mk - Example Structure
LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := libmycamera LOCAL_SRC_FILES := camera.cpp utils.cpp LOCAL_C_INCLUDES := $(LOCAL_PATH)/include LOCAL_SHARED_LIBRARIES := liblog libcutils LOCAL_MODULE_TAGS := optional include $(BUILD_SHARED_LIBRARY) # ↑ # could also be: # BUILD_STATIC_LIBRARY # BUILD_EXECUTABLE # BUILD_PACKAGE (for APKs)
Android.bp - The Modern Soong System
Android.bp uses Blueprint syntax - a declarative, JSON-like format. Soong converts .bp files into Ninja build files which are then executed. Soong is faster, parallel-friendly, and much easier to understand. All new AOSP modules should use Android.bp.
Android.bp - Example Structure
cc_library_shared {
name: "libmycamera",
srcs: [
"camera.cpp",
"utils.cpp",
],
include_dirs: ["include"],
shared_libs: [
"liblog",
"libcutils",
],
vendor: true, // installs to /vendor
}
// Other module types:
// cc_binary → executable
// cc_library_static → static library (.a)
// java_library → Java library
// android_app → APKKey Differences
- ▸Syntax - Android.mk uses GNU Make macros; Android.bp uses clean declarative Blueprint syntax
- ▸Speed - Soong with Ninja is significantly faster than plain Make for large builds
- ▸Correctness - .bp files are validated by the build system; .mk files can silently misbehave
- ▸Android.mk is still needed for some legacy cases and is still supported, but all new code should use .bp
- ▸vendor: true / system_ext: true - in .bp files, this controls which partition the module installs to
Common Module Types in Android.bp
- ▸cc_binary - C/C++ executable (daemons, tools)
- ▸cc_library_shared - shared library (.so)
- ▸cc_library_static - static library (.a)
- ▸java_library - Java library (.jar)
- ▸android_app - Android APK
- ▸rust_binary / rust_library - Rust modules
- ▸prebuilt_etc - install a prebuilt file to /etc or similar
- ▸sh_binary - shell script installed as executable