自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
產生供應商快照
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Android 11 支援 VNDK 快照建構構件和供應商快照,無論來源樹狀結構中的 Android 版本為何,您都可以使用這些快照建構 vendor.img
。這可讓您使用不同版本的映像檔,例如較舊的供應商和較新的系統映像檔。
以下功能不支援混合圖片版本:
關於供應商快照
供應商快照是指原始設備製造商 (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 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[[["容易理解","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,["# 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`."]]