自 2025 年 3 月 27 日起,我们建议您使用 android-latest-release
而非 aosp-main
构建 AOSP 并为其做出贡献。如需了解详情,请参阅 AOSP 的变更。
生成供应商快照
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Android 11 支持 VNDK 快照构建工件和供应商快照,可用于构建 vendor.img
,无论源代码树的 Android 版本如何。这样可以实现映像版本(如较旧的供应商映像和较新的系统映像)的混合。
以下对象不支持混合映像版本。
关于供应商快照
供应商快照是 OEM 拥有的快照。它是一组预构建的 C++ 模块,安装在 /vendor
中,但在 AOSP 中维护。如果没有捕获旧 Android 版本的供应商快照,升级到新 Android 版本可能会破坏供应商分区,因为供应商快照模块可以在不具备 API 或 ABI 兼容性的情况下移除或更改。
供应商快照包含 AOSP 中的以下模块。
- 满足
vendor: true
或 vendor_available:
true
的共享库、静态库和头文件库
- 满足
vendor_available: true
的 VNDK 静态库
- 满足
vendor: true
或 vendor_available: true
的可执行文件和对象文件
以下目录下的模块被视为 SoC 拥有的硬件代码,将被忽略。
device/
vendor/
hardware/
,以下目录除外:
hardware/interfaces
hardware/libhardware
hardware/libhardware_legacy
SoC 拥有的硬件代码也可能存在于其他目录中。目前,供应商快照不支持此类配置。
构建供应商快照
使用以下命令构建供应商快照。
. build/envsetup.sh
lunch target
m dist vendor-snapshot
这些命令会在 $DIST_DIR
中创建一个 vendor-$(TARGET_DEVICE).zip
文件。以下示例显示的是供应商快照 ZIP 文件:
vendor-$(TARGET_DEVICE).zip
├── arch-arm64-armv8-a
│ ├── binary -> binary files, *.json files
│ ├── header -> *.json files
│ ├── object -> *.o files, *.json files
│ ├── shared -> *.so files, *.json files
│ └── static -> *.a files, *.json files
├── arch-arm-armv8-a -> (arch-arm64-armv8-a)
├── configs -> *.rc files, *.xml files
├── include -> exported header files (*.h, *.hh, etc.)
└── NOTICE_FILES -> license txt files
- JSON 文件包含模块名称、导出目录、
init_rc
文件和 vintf_fragments
文件等标志。
configs
目录包含 init_rc
和 vintf_fragments
标志的 .rc
和 .xml
文件。
安装供应商快照
如需安装供应商快照,请转到目标目录并使用以下命令。
python3 development/vendor_snapshot/update.py --local $DIST_DIR --install-dir \
vendor/vendor name/vendor_snapshot VER
此命令会生成 /vendor/vendor name/vendor_snapshot/vVER/$(TARGET_ARCH)/Android.bp
。以下示例显示的是供应商快照的目录结构。
vendor/vendor name/vendor_snapshot/
├── v30
│ ├── arm64
│ │ ├── arch-arm64-armv8-a
│ │ │ ├── binary -> (prebuilt libs)
│ │ │ ├── object -> (prebuilt libs)
│ │ │ ├── shared -> (prebuilt libs)
│ │ │ └── static -> (prebuilt libs)
│ │ ├── arch-arm-armv8-a -> (same as above)
│ │ ├── configs -> (config files)
│ │ ├── include -> (exported header files)
│ │ ├── NOTICE_FILES -> (license files)
│ │ └── Android.bp -> (snapshot modules)
│ ├── arm -> (same as above)
│ ├── x86_64 -> (same as above)
│ └── x86 -> (same as above)
└── (other vendor versions) -> (same as above)
构建供应商映像
使用 VNDK 快照构建工件和供应商快照,无论源代码树中的 Android 版本如何,您都可以构建 vendor.img
,从而创建混合版映像。安装 VNDK 快照和供应商快照后,将 BOARD_VNDK_VERSION
设置为供应商的版本。例如:
# BoardConfig.mk
BOARD_VNDK_VERSION := 29
当 BOARD_VNDK_VERSION
设置为 current
以外的值时,构建系统会执行以下操作:
- 启用
BOARD_VNDK_VERSION
的 VNDK 快照模块和供应商快照模块。每个快照模块会替换具有相同名称的 C++ 源代码模块。
- 将
ro.vndk.version
设置为 BOARD_VNDK_VERSION
。
- 将
BOARD_VNDK_VERSION
的 VNDK 快照模块安装到 system_ext
。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-03-26。
[[["易于理解","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"]],["最后更新时间 (UTC):2025-03-26。"],[],[],null,["# Generate vendor snapshots\n\nAndroid 11 supports [VNDK snapshot build\nartifacts](/docs/core/architecture/vndk/snapshot-generate#vendor-snapshots)\nand vendor snapshots, which you can use to build `vendor.img` regardless of the\nAndroid version on the source tree. This enables mixed versions of images, such\nas an older vendor and a newer system image.\n\nMixed image versions aren't supported for the following.\n\n- `Android.mk.` Because Soong generates the vendor snapshot, modules defined in\n `Android.mk` aren't captured as a vendor snapshot (SoC-proprietary modules in\n `Android.mk` also aren't guaranteed to work).\n\n- **Sanitizer.** Vendor and VNDK snapshots don't support sanitizer as sanitizer\n variants need to be built separately.\n\nAbout vendor snapshots\n----------------------\n\nA vendor snapshot is an OEM-owned snapshot. It's a set of prebuilt C++ modules\ninstalled in `/vendor` but maintained on AOSP. Without capturing a vendor\nsnapshot of the previous Android version, upgrading to a new Android version\nmight break the vendor partition because vendor snapshot modules can be removed\nor changed without API or ABI compatibility.\n\nA vendor snapshot contains following modules on AOSP.\n\n- Shared, static, and header libraries with `vendor: true` or `vendor_available:\n true`\n- VNDK static libraries with `vendor_available: true`\n- Executables and object files with `vendor: true` or `vendor_available: true`\n\nModules under the following directories are considered SoC-owned hardware code\nand are ignored.\n\n- `device/`\n- `vendor/`\n- `hardware/`, except for\n - `hardware/interfaces`\n - `hardware/libhardware`\n - `hardware/libhardware_legacy`\n\nSoC-owned hardware codes might also exist in other directories. At this time,\nvendor snapshots don't support such configurations.\n\nBuild vendor snapshots\n----------------------\n\nBuild a vendor snapshot using the following commands. \n\n . build/envsetup.sh\n lunch \u003cvar translate=\"no\"\u003etarget\u003c/var\u003e\n m dist vendor-snapshot\n\nThese commands create a `vendor-$(TARGET_DEVICE).zip` file in\n`$DIST_DIR`. The following example shows a vendor snapshot zip file: \n\n vendor-$(TARGET_DEVICE).zip\n ├── arch-arm64-armv8-a\n │ ├── binary -\u003e binary files, *.json files\n │ ├── header -\u003e *.json files\n │ ├── object -\u003e *.o files, *.json files\n │ ├── shared -\u003e *.so files, *.json files\n │ └── static -\u003e *.a files, *.json files\n ├── arch-arm-armv8-a -\u003e (arch-arm64-armv8-a)\n ├── configs -\u003e *.rc files, *.xml files\n ├── include -\u003e exported header files (*.h, *.hh, etc.)\n └── NOTICE_FILES -\u003e license txt files\n\n- The JSON files contain flags such as module name, exported directories, `init_rc` files, and `vintf_fragments` files.\n- The `configs` directory contains `.rc` and `.xml` files from flags `init_rc` and `vintf_fragments`.\n\nInstall vendor snapshots\n------------------------\n\n| **Note:** For details on uploading VNDK snapshots, see [Using locally built VNDK\n| snapshots](/docs/core/architecture/vndk/snapshot-generate#using-local-snapshots).\n\nTo install a vendor snapshot, navigate to the destination directory and use the\nfollowing commands. \n\n python3 development/vendor_snapshot/update.py --local $DIST_DIR --install-dir \\\n vendor/\u003cvar translate=\"no\"\u003evendor\u003cspan class=\"devsite-syntax-w\"\u003e \u003c/span\u003ename\u003c/var\u003e/vendor_snapshot \u003cvar translate=\"no\"\u003eVER\u003c/var\u003e\n\nThis command generates\n`/vendor/`\u003cvar translate=\"no\"\u003evendor name\u003c/var\u003e`/vendor_snapshot/v`\u003cvar translate=\"no\"\u003eVER\u003c/var\u003e`/$(TARGET_ARCH)/Android.bp`.\nThe following example shows the directory structure of a vendor snapshot: \n\n vendor/\u003cvar translate=\"no\"\u003evendor name\u003c/var\u003e/vendor_snapshot/\n ├── v30\n │ ├── arm64\n │ │ ├── arch-arm64-armv8-a\n │ │ │ ├── binary -\u003e (prebuilt libs)\n │ │ │ ├── object -\u003e (prebuilt libs)\n │ │ │ ├── shared -\u003e (prebuilt libs)\n │ │ │ └── static -\u003e (prebuilt libs)\n │ │ ├── arch-arm-armv8-a -\u003e (same as above)\n │ │ ├── configs -\u003e (config files)\n │ │ ├── include -\u003e (exported header files)\n │ │ ├── NOTICE_FILES -\u003e (license files)\n │ │ └── Android.bp -\u003e (snapshot modules)\n │ ├── arm -\u003e (same as above)\n │ ├── x86_64 -\u003e (same as above)\n │ └── x86 -\u003e (same as above)\n └── (other vendor versions) -\u003e (same as above)\n\nBuild vendor images\n-------------------\n\nUsing [VNDK snapshot build\nartifacts](/docs/core/architecture/vndk/snapshot-generate#vendor-snapshots)\nand a vendor snapshot, you can build `vendor.img` regardless of the Android\nversion on the source tree, making it possible to create mixed versions of\nimages. After installing both the VNDK snapshot and vendor snapshot, set\n`BOARD_VNDK_VERSION` to the vendor's version. For example: \n\n # BoardConfig.mk\n BOARD_VNDK_VERSION := 29\n\nWhen `BOARD_VNDK_VERSION` is set to a value other than `current`, the build\nsystem:\n\n- Enables VNDK snapshot modules and vendor snapshot modules of `BOARD_VNDK_VERSION`. Each snapshot module overrides a C++ source module having the same name.\n- Sets `ro.vndk.version` to `BOARD_VNDK_VERSION`.\n- Installs VNDK snapshot modules of `BOARD_VNDK_VERSION` to `system_ext`."]]