Kể từ ngày 27 tháng 3 năm 2025, bạn nên sử dụng android-latest-release
thay vì aosp-main
để xây dựng và đóng góp cho AOSP. Để biết thêm thông tin, hãy xem phần Thay đổi đối với AOSP.
Tiện ích SDK
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Mô-đun Tiện ích SDK quyết định cấp độ SDK tiện ích của thiết bị và cung cấp API để ứng dụng truy vấn cấp độ SDK tiện ích. Mô-đun này có thể cập nhật, nghĩa là có thể nhận được bản cập nhật về chức năng bên ngoài chu kỳ phát hành Android thông thường.
Tiện ích SDK chịu trách nhiệm về:
- Quyết định cấp độ SDK tiện ích của thiết bị.
- Cung cấp API cho ứng dụng để truy vấn cấp độ SDK tiện ích.
- (Kể từ Android 12) Xác định giá trị cho các biến môi trường
BOOTCLASSPATH
, DEX2OATBOOTCLASSPATH
và SYSTEMSERVERCLASSPATH
.
Mô-đun Tiện ích SDK (com.android.sdkext
) ở định dạng APEX và có sẵn cho các thiết bị chạy Android 11 trở lên.
Mô-đun Tiện ích SDK (com.google.android.sdkext
) ở định dạng APEX và chứa các thành phần sau:
(Kể từ Android 12) bin/derive_classpath
: Tệp nhị phân gốc chạy sớm trong quá trình khởi động thiết bị. Tệp này đọc các tệp cấu hình đường dẫn lớp riêng lẻ từ hệ thống và các mô-đun khác, hợp nhất các tệp đó và xác định định nghĩa của các biến môi trường CLASSPATH
.
bin/derive_sdk
: Tệp nhị phân gốc chạy sớm trong quá trình khởi động thiết bị và đọc siêu dữ liệu của các mô-đun khác để đặt các thuộc tính hệ thống liên quan đến SDK tiện ích (ví dụ: build.version.extensions.r
).
javalib/framework-sdkextension.jar
: Tệp này nằm trên đường dẫn lớp khởi động hiển thị các API cho ứng dụng để truy vấn cấp độ SDK của tiện ích.
Trích xuất cấp SDK của tiện ích
Chương trình derive_sdk
đọc siêu dữ liệu được lưu trữ dưới dạng tệp protobuf nhị phân trong đường dẫn phụ etc/sdkinfo.binarypb
bên trong mỗi mô-đun APEX. Để biết thông tin chi tiết về cấu trúc protobuf, hãy tham khảo tệp protobuf
.
Đọc cấp độ SDK của tiện ích
Mô-đun Tiện ích SDK hiển thị một lớp java SdkExtensions
trong gói android.os.ext
. Sử dụng phương thức getExtensionVersion(int)
để đọc phiên bản của tiện ích SDK (ví dụ: getExtensionVersion(Build.VERSION_CODES.R)
).
Lấy đường dẫn lớp
Dịch vụ derive_classpath
đọc và hợp nhất các tệp cấu hình riêng lẻ trong /system/etc/classpaths/
và /apex/*/etc/classpaths/
. Mỗi cấu hình lưu trữ thông báo protobuf từ classpaths.proto
ở định dạng tệp nhị phân proto. Thuật toán hợp nhất chính xác xác định thứ tự của các mục nhập đường dẫn lớp được mô tả trong derive_classpath.cpp
và có thể thay đổi theo thời gian.
Nội dung và mã mẫu trên trang này phải tuân thủ các giấy phép như mô tả trong phần Giấy phép nội dung. Java và OpenJDK là nhãn hiệu hoặc nhãn hiệu đã đăng ký của Oracle và/hoặc đơn vị liên kết của Oracle.
Cập nhật lần gần đây nhất: 2025-07-27 UTC.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-07-27 UTC."],[],[],null,["# SDK Extensions\n\nThe SDK Extensions module decides the extension SDK level of the device and\nprovides APIs for apps to query the extension SDK level. This module is\nupdatable, meaning it can receive updates to functionality outside of the normal\nAndroid release cycle.\n\nSDK Extensions is responsible for:\n\n- Deciding the extension SDK level of the device.\n- Providing APIs for apps to query the extension SDK level.\n- (Starting Android 12) Determining the values for the `BOOTCLASSPATH`, `DEX2OATBOOTCLASSPATH`, and `SYSTEMSERVERCLASSPATH` environment variables.\n\nModule format\n-------------\n\nThe SDK Extensions module (`com.android.sdkext`) is in\n[APEX](/docs/core/ota/apex) format and is available for devices\nrunning Android 11 or higher.\n\nPackage format\n--------------\n\nThe SDK Extensions module (`com.google.android.sdkext`) is in\n[APEX](/devices/tech/ota/apex) format and\ncontains the following components:\n\n- (Starting Android 12) `bin/derive_classpath`: A\n native binary that runs early in the device boot\n process. It reads individual classpath configs files from the system and\n other modules, merges them, and defines the definition of `CLASSPATH`\n environment variables.\n\n- `bin/derive_sdk`: A native binary that runs early in the device boot process\n and reads metadata of other modules to set system properties related to the\n extension SDK (for example, `build.version.extensions.r`).\n\n- `javalib/framework-sdkextension.jar`: This file is on the bootclasspath that\n exposes APIs to apps to query the extension SDK level.\n\nDerive extension SDK level\n--------------------------\n\nThe `derive_sdk` program reads metadata stored as binary protobuf files in the\n`etc/sdkinfo.binarypb` subpath inside each APEX module. For details on protobuf\nstructure, refer to the\n[`protobuf`](https://android.googlesource.com/platform/external/protobuf.git)\nfile.\n\nRead extension SDK level\n------------------------\n\nThe SDK Extensions module exposes an\n[`SdkExtensions`](https://android.googlesource.com/platform/packages/modules/SdkExtensions/)\njava class in the `android.os.ext` package. Use the `getExtensionVersion(int)`\nmethod to read the version of an SDK extension (for example,\n`getExtensionVersion(Build.VERSION_CODES.R)`).\n\nDerive classpaths\n-----------------\n\nThe `derive_classpath` service reads and merges individual config files in\n`/system/etc/classpaths/` and `/apex/*/etc/classpaths/`. Each config stores\nprotobuf message from [`classpaths.proto`](https://android.googlesource.com/platform/packages/modules/common/+/android16-release/proto/classpaths.proto)\nin a proto binary format. The exact merging algorithm that determines the order\nof the classpath entries is described in\n[`derive_classpath.cpp`](https://android.googlesource.com/platform/packages/modules/SdkExtensions/+/android16-release/derive_classpath/derive_classpath.cpp)\nand might change over time."]]