[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],null,["# VNDK snapshot design\n\nVNDK snapshots can be used by a system image to provide the correct VNDK\nlibraries to vendor images even when system and vendor images are built from\ndifferent versions of Android. Creating a VNDK snapshot requires capturing\nVNDK libraries as a snapshot and marking them with a version number. The\nvendor image may link with a specific VNDK version that provides required ABIs\nfor the modules in the vendor image. However, within the same VNDK version,\nthe VNDK libraries must be\n[ABI-stable](/docs/core/architecture/hidl/hashing#abi-stability).\n\n\nVNDK snapshot design includes methods for\n[generating the\npre-builds of a VNDK snapshot](/docs/core/architecture/vndk/snapshot-generate) from the current system image and\n[installing\nthose pre-built libs](/docs/core/architecture/vndk/snapshot-generate#install-vndk-snapshot) to the system partition of a newer Android version.\n\nAbout VNDK libraries\n--------------------\n\n\n[HIDL-HALs](/docs/core/architecture#hidl), introduced in\nAndroid 8.0, enables separate upgrades for system and vendor partitions. VNDK\ndefines sets of libraries (VNDK-core, VNDK-SP and LL-NDK) that vendor code can\nlink with and blocks the vendors from using libraries that are not in a VNDK\nset. As a result, the vendor image can be built and run if the proper VNDK\nsets on the system image are provided to the vendor image.\n| **Note:** For details on these libraries, refer to [VNDK concepts](/docs/core/architecture/vndk#concepts).\n\n### VNDK-core\n\n\nThe VNDK-core set of libraries is installed in\n`/system/lib[64]/vndk-${VER}` and is available\n**only** for vendor processes with the API level equal to\n`${VER}`. System processes may not use these libraries and must\ninstead use the libraries installed in `/system/lib[64]`. Because\nof the strict namespace restriction for each process, the VNDK-core libraries\nare safe from dual-loading.\n\nTo include a library in VNDK-core, add the following to\n`Android.bp`: \n\n```actionscript-3\nvendor_available: true,\nvndk: {\n enabled: true,\n},\n```\n| **Note:** If a system process loads library `foo.so` from `system/lib` and loads another `foo.so` from `system/lib/vndk`, `foo.so` is dual-loaded. Normally it is unsafe to load the same library twice in a process.\n\n### VNDK-SP\n\n\nVNDK-SP libraries are installed in `/system/lib[64]/vndk-sp-${VER}`\nand are available to vendor processes and system processes (through the SP-HAL\nlibraries installed in vendor partition). VNDK-SP libraries may be\ndual-loaded.\n\n\nTo include a library in VNDK-SP, add the following to `Android.bp`: \n\n```actionscript-3\nvendor_available: true,\nvndk: {\n enabled: true,\n support_system_process: true,\n},\n```\n\n### LL-NDK\n\n\nLL-NDK libraries are installed in `/system/lib[64]`. Vendor modules\ncan use LL-NDK stub libraries to access pre-selected symbols of LL-NDK\nlibraries. LL-NDK libraries must be backward-compatible and ABI-stable to\nenable old versions of vendor modules to use new versions of LL-NDK libraries.\nBecause of the ABI-stable characteristics of LL-NDK, the VNDK snapshot does\nnot need to include LL-NDK libraries for old vendor images.\n\nAbout VNDK snapshots\n--------------------\n\n\nAndroid 8.1 included [VNDK\nlibraries built from the source code](/docs/core/architecture/vndk/build-system). However, for later versions of\nAndroid, each VNDK version must be captured as a snapshot and provided as a\npre-build to enabling linking to an older vendor image.\n\n\nStarting in Android 9, new versions of Android will\ninclude at least one snapshot of VNDK-core and VNDK-SP directories for older\nversions in the Android source code. At build time, required snapshots will be\ninstalled to `/system/lib[64]/vndk-${VER}` and\n`/system/lib[64]/vndk-sp-${VER}` (directories that can be used by\nthe vendor partition), where `${VER}` is the string variable that\nrepresents the version name of the VNDK snapshot.\n\n\nAs the VNDK snapshot libraries may differ for each VNDK version, the VNDK\nsnapshot also includes the linker namespace configurations, installed as\n`etc/ld.config.${VER}.txt`,\n`/etc/llndk.libraries.${VER}.txt`, and\n`/etc/vndksp.libraries.${VER}.txt`.\n\n### Example: Upgrade system and vendor\nimages\n\n\nNo snapshot required; build without additional configurations for VNDK\nsnapshots.\n\n### Example: Upgrade system image only\n\n\nMust include the VNDK snapshot and linker namespace configuration files for\nthe vendor image in the system image. The linker namespace configuration files\nare automatically configured to search for VNDK libraries in\n`/system/lib[64]/vndk-${VER}` and\n`/system/lib[64]/vndk-sp-${VER}`.\n**Figure 1.** Upgrading system only\n\n### Example: Upgrade system image, minor vendor image change\n\n\nBuilding a vendor image against a VNDK snapshot is not yet supported, so you\nmust build the vendor image separately with its original source code, then\nupgrade the system image as described in the previous example.\n\nVNDK snapshot architecture\n--------------------------\n\n\nTo make an Android 9 system image compatible with an\nAndroid 8.1 vendor image, the VNDK snapshot that matches the Android 8.1\nvendor image must be provided with the Android 9\nsystem image, as shown below:\n**Figure 2.** VNDK snapshot architecture\n\n\nThe VNDK snapshot design includes the following methods:\n\n- **Generating a snapshot for VNDK-core and VNDK-SP\n libraries** . Android 9 includes a script you can use to make a snapshot of the current VNDK build. This script bundles all libraries in `/system/lib[64]/vndk-28` and `/system/lib[64]/vndk-sp-28` that were built with the current source as a VNDK snapshot, where `28` is the VNDK version of Android 9. The snapshot also includes the linker namespace configuration files `/etc/ld.config.28.txt`, `/etc/llndk.libraries.28.txt`, and `/etc/vndksp.libraries.28.txt`. The generated snapshot will be used with newer Android versions (higher than Android 9).\n- **Installing pre-built VNDK-core and VNDK-SP libraries from a\n snapshot** . In Android 9, a VNDK snapshot has a set of pre-built VNDK-core libraries and a set of VNDK-SP libraries, as well as linker namespace configuration files. When you provide a list of VNDK snapshot versions to be installed, at build time, the system image installs the VNDK snapshot libraries to `/system/lib[64]/vndk-${VER}` and the `/system/lib[64]/vndk-sp-${VER}` directories and linker namespace configuration files for those VNDK snapshots to `/etc` directory.\n\n### VNDK versioning\n\n\nEach Android release has only one VNDK snapshot and the SDK version is used as\na VNDK version (which means the VNDK version has an integer number, such as 27\nfor Android 8.1). The VNDK version is fixed when the Android version is\nreleased. The VNDK version used by the vendor partition is stored\nautomatically in the `ro.vndk.version` property, which can be read\non runtime. This version is then used in identifying the vendor VNDK version\nfor some libraries and identifying the VNDK snapshot version for namespace\nconfiguration.\n\n### Build VNDK libraries\n\n\nThe `make vndk` command builds libraries that have `vndk:\n{ enabled: true, ... }`, including dependencies and namespace\nconfiguration files. If `BOARD_VNDK_VERSION := current` is set,\nthese libraries are built with the `make` command.\n\n\nBecause this build does not install the VNDK libraries from the snapshot, the\ninstalled VNDK libraries are not ABI-stable. However, when an Android version\nis released, the ABI for the current VNDK version is fixed. At this point, any\nABI breakage is a build error, so patches to the Android version must not\nchange the ABI for VNDK libraries."]]