{% include "_versions.html" %}

The Vendor Native Development Kit (VNDK) is a set of libraries exclusively for vendors to implement their HALs. The VNDK ships in system.img and is dynamically linked to vendor code at runtime.

Why VNDK?

Android 8.0 and higher enables framework-only updates in which the system partition can be upgraded to the latest version while vendor partitions are left unchanged. This implies that binaries built at different times must be able to work with each other; VNDK covers API/ABI changes across Android releases.

Framework-only updates include the following challenges:

To address these challenges, Android 8.0 introduces several techniques such as VNDK (described in this section), HIDL, hwbinder, device tree overlay, and sepolicy overlay.

VNDK resources

This section includes the following VNDK resources:

VNDK concepts

In an ideal Android 8.0 and higher world, framework processes do not load vendor shared libraries, all vendor processes load only vendor shared libraries (and a portion of framework shared libraries), and communications between framework processes and vendor processes are governed by HIDL and hardware binder.

Such a world includes the possibility that stable, public APIs from framework shared libraries might not be sufficient for vendor module developers (although APIs can change between Android releases), requiring that some portion of framework shared libraries be accessible to vendor processes. In addition, as performance requirements can lead to compromises, some response-time-critical HALs must be treated differently.

The following sections detail how VNDK handles framework shared libraries for vendors and Same-Process HALs (SP-HALs).

Framework shared libraries for vendor

This section describes the criteria for classifying shared libraries that are accessible to vendor processes. There are two approaches to support vendor modules across multiple Android releases:

  1. Stabilize the ABIs/APIs of the framework shared libraries. New framework modules and old vendor modules can use the same shared library to reduce memory footprint and storage size. A unique shared library also avoids several double-loading issues. However, the development cost to maintain stable ABIs/APIs is high and it is unrealistic to stabilize all ABIs/APIs exported by every framework shared library.
  2. Copy old framework shared libraries. Comes with the strong restriction against side channels, defined as all mechanisms to communicate among framework modules and vendor modules, including (but not limited to) binder, socket, pipe, shared memory, shared file, and system properties. There must be no communication unless the communication protocol is frozen and stable (e.g. HIDL through hwbinder). Double-loading shared libraries might cause problems as well; for example, if an object created by the new library is passed into the functions from the old library, an error may occur as these libraries may interpret the object differently.

Different approaches are used depending on the characteristics of the shared libraries. As a result, framework shared libraries are classified into three sub-categories:

Same-Process HAL (SP-HAL)

Same-Process HAL (SP-HAL) is a set of predetermined HALs implemented as Vendor Shared Libraries and loaded into Framework Processes. SP-HALs are isolated by a linker namespace (controls the libraries and symbols that are visible to the shared libraries). SP-HALs must depend only on LL-NDK and VNDK-SP.

VNDK-SP is a predefined subset of eligible VNDK libraries. VNDK-SP libraries are carefully reviewed to ensure double-loading VNDK-SP libraries into framework processes does not cause problems. Both SP-HALs and VNDK-SPs are defined by Google.

The following libraries are approved SP-HALs:

The following libraries are VNDK-SP libraries that are accessible by SP-HALs:

The following VNDK-SP dependencies (VNDK-SP-Private) are invisible to SP-HALs:

The following are framework-only libraries with RS exceptions (FWK-ONLY-RS):

VNDK terminology

For example:

VNDK versioning

In Android {{ androidPVersionNumber }}, VNDK shared libraries are versioned:

The value of ro.vndk.version is chosen by the algorithm below:

Upgrading devices

If an Android 8.x device disabled VNDK run-time enforcement (i.e. either built without BOARD_VNDK_VERSION or built with BOARD_VNDK_RUNTIME_DISABLE), it may add PRODUCT_USE_VNDK_OVERRIDE := false to BoardConfig.mk while upgrading to Android {{ androidPVersionNumber }}.

If PRODUCT_USE_VNDK_OVERRIDE is false, the ro.vndk.lite property will be automatically added to /vendor/default.prop and its value will be true. Consequently, the dynamic linker will load the linker namespace configuration from /system/etc/ld.config.vndk_lite.txt, which isolates only SP-HAL and VNDK-SP.

To upgrade an Android 7.0 or lower device to Android {{ androidPVersionNumber }}, add PRODUCT_TREBLE_LINKER_NAMESPACES_OVERRIDE := false to BoardConfig.mk.

Vendor Test Suite (VTS)

The Android {{ androidPVersionNumber }} Vendor Test Suite (VTS) mandates a non-empty ro.vndk.version property. Both newly-launched devices and upgrading devices must define ro.vndk.version. Some VNDK test cases (e.g. VtsVndkFilesTest and VtsVndkDependencyTest) rely on the ro.vndk.version property to load the matching eligible VNDK libraries data sets.

If the ro.product.first_api_level property is greater than 27, the ro.vndk.lite property must not be defined. VtsTreblePlatformVersionTest will fail if ro.vndk.lite is defined in a newly-launched Android {{ androidPVersionNumber }} device.

Document history

This section tracks changes to VNDK documentation.

Android {{ androidPVersionNumber }} changes

Android 8.1 changes