ตั้งแต่วันที่ 27 มีนาคม 2025 เป็นต้นไป เราขอแนะนำให้ใช้ android-latest-release
แทน aosp-main
เพื่อสร้างและมีส่วนร่วมใน AOSP โปรดดูข้อมูลเพิ่มเติมที่หัวข้อการเปลี่ยนแปลงใน AOSP
ส่วนขยาย SDK
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
โมดูลส่วนขยาย SDK จะกำหนดระดับ SDK ส่วนขยายของอุปกรณ์และให้บริการ API สําหรับแอปเพื่อค้นหาระดับ SDK ส่วนขยาย โมดูลนี้อัปเดตได้ ซึ่งหมายความว่าจะได้รับการอัปเดตฟังก์ชันการทำงานนอกรอบการเผยแพร่ปกติของ Android
ส่วนขยาย SDK มีหน้าที่รับผิดชอบในเรื่องต่อไปนี้
- การกำหนดระดับ SDK ของส่วนขยายของอุปกรณ์
- ระบุ API สําหรับแอปเพื่อค้นหาระดับ SDK ของส่วนขยาย
- (ตั้งแต่ Android 12 เป็นต้นไป) การกำหนดค่าสำหรับตัวแปรสภาพแวดล้อม
BOOTCLASSPATH
, DEX2OATBOOTCLASSPATH
และ SYSTEMSERVERCLASSPATH
โมดูลส่วนขยาย SDK (com.android.sdkext
) อยู่ในรูปแบบ APEX และพร้อมใช้งานสำหรับอุปกรณ์ที่ใช้ Android 11 ขึ้นไป
โมดูลส่วนขยาย SDK (com.google.android.sdkext
) อยู่ในรูปแบบ APEX และประกอบด้วยคอมโพเนนต์ต่อไปนี้
(ตั้งแต่ Android 12 เป็นต้นไป) bin/derive_classpath
: ไฟล์ไบนารีแบบเนทีฟที่ทำงานในช่วงต้นของกระบวนการบูตอุปกรณ์ โดยจะอ่านไฟล์การกําหนดค่า classpath แต่ละไฟล์จากระบบและข้อบังคับอื่นๆ ผสานไฟล์เหล่านั้น และกำหนดคำจำกัดความของCLASSPATH
ตัวแปรสภาพแวดล้อม
bin/derive_sdk
: ไฟล์ไบนารีแบบเนทีฟที่ทำงานในช่วงต้นของกระบวนการบูตอุปกรณ์ และอ่านข้อมูลเมตาของโมดูลอื่นๆ เพื่อตั้งค่าพร็อพเพอร์ตี้ของระบบที่เกี่ยวข้องกับ SDK ส่วนขยาย (เช่น build.version.extensions.r
)
javalib/framework-sdkextension.jar
: ไฟล์นี้อยู่ในบูตไนพแอตที่นำ API ไปแสดงในแอปเพื่อค้นหาระดับ SDK ของส่วนขยาย
ดึงข้อมูลระดับ SDK ของส่วนขยาย
โปรแกรม derive_sdk
จะอ่านข้อมูลเมตาที่จัดเก็บเป็นไฟล์ protobuf แบบไบนารีในเส้นทางย่อย etc/sdkinfo.binarypb
ภายในโมดูล APEX แต่ละรายการ ดูรายละเอียดเกี่ยวกับโครงสร้าง protobuf ได้ในไฟล์ protobuf
อ่านระดับ SDK ของส่วนขยาย
โมดูลส่วนขยาย SDK จะแสดงคลาส SdkExtensions
Java ในแพ็กเกจ android.os.ext
ใช้getExtensionVersion(int)
วิธีอ่านเวอร์ชันของส่วนขยาย SDK (เช่น getExtensionVersion(Build.VERSION_CODES.R)
)
ดึงข้อมูล classpath
บริการ derive_classpath
จะอ่านและผสานไฟล์การกําหนดค่าแต่ละไฟล์ใน /system/etc/classpaths/
และ /apex/*/etc/classpaths/
การกําหนดค่าแต่ละรายการจะจัดเก็บข้อความ protobuf จาก classpaths.proto
ในรูปแบบไบนารีของโปรโต อัลกอริทึมการผสานที่แน่นอนซึ่งกำหนดลําดับของรายการ classpath อธิบายไว้ใน derive_classpath.cpp
และอาจเปลี่ยนแปลงได้เมื่อเวลาผ่านไป
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-27 UTC
[[["เข้าใจง่าย","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 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."]]