← Back to Blogs

Android.bp and Android.mk Files

Build system files in AOSP - what they do and how to use them

1 min read

When 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    → APK

Key Differences

Common Module Types in Android.bp

To check what a module builds to: run 'lunch <target> && m <module_name>' from the AOSP root. Use 'adb shell find /system /vendor -name libmycamera.so' to verify where an .so was installed on device.