SDK Extensions

The SDK Extensions module decides the extension SDK level of the device and provides APIs for apps to query the extension SDK level. This module is updatable, meaning it can receive updates to functionality outside of the normal Android release cycle.

SDK Extensions is responsible for:

  • Deciding the extension SDK level of the device.
  • Providing APIs for apps to query the extension SDK level.
  • (Starting Android 12) Determining the values for the BOOTCLASSPATH, DEX2OATBOOTCLASSPATH, and SYSTEMSERVERCLASSPATH environment variables.

Module format

The SDK Extensions module (com.android.sdkext) is in APEX format and is available for devices running Android 11 or higher.

Package format

The SDK Extensions module (com.google.android.sdkext) is in APEX format and contains the following components:

  • (Starting Android 12) bin/derive_classpath: A native binary that runs early in the device boot process. It reads individual classpath configs files from the system and other modules, merges them, and defines the definition of CLASSPATH environment variables.

  • bin/derive_sdk: A native binary that runs early in the device boot process and reads metadata of other modules to set system properties related to the extension SDK (for example, build.version.extensions.r).

  • javalib/framework-sdkextension.jar: This file is on the bootclasspath that exposes APIs to apps to query the extension SDK level.

Derive extension SDK level

The derive_sdk program reads metadata stored as binary protobuf files in the etc/sdkinfo.binarypb subpath inside each APEX module. For details on protobuf structure, refer to the protobuf file.

Read extension SDK level

The SDK Extensions module exposes an SdkExtensions java class in the android.os.ext package. Use the getExtensionVersion(int) method to read the version of an SDK extension (for example, getExtensionVersion(Build.VERSION_CODES.R)).

Derive classpaths

The derive_classpath service reads and merges individual config files in /system/etc/classpaths/ and /apex/*/etc/classpaths/. Each config stores protobuf message from classpaths.proto in a proto binary format. The exact merging algorithm that determines the order of the classpath entries is described in derive_classpath.cpp and might change over time.