- ไวยากรณ์:
<profileable android:shell=["true" | "false"] android:enabled=["true" | "false"] />
- ที่อยู่ใน:
<application>
- description:
- ระบุว่าผู้เขียนโปรไฟล์จะเข้าถึงแอปพลิเคชันนี้ได้อย่างไร
- ดังนี้
android:shell
-
ระบุว่าผู้ใช้อุปกรณ์สามารถสร้างโปรไฟล์ให้กับแอปพลิเคชันนี้ผ่านการแก้ไขข้อบกพร่องในเครื่องได้หรือไม่
เครื่องมือดังต่อไปนี้
- API การติดตาม
android.os.Trace
รายการ (Android 11 และต่ำกว่า) simpleperf
- คำสั่ง
am profile
รายการ perfetto
โปรไฟล์เลอร์ (หน่วยความจำในเครื่อง, หน่วยความจำ Java, CPU)
false
เครื่องมือและ API เหล่านี้จะทำงานเมื่อแอปdebuggable
แอปที่แก้ไขข้อบกพร่องได้จะมีประสิทธิภาพลดลงอย่างมากและหลากหลาย และไม่เป็นประโยชน์สำหรับ สามารถวัดช่วงเวลาได้อย่างแม่นยำ ขอแนะนำอย่างยิ่งให้ใช้องค์ประกอบนี้สำหรับประสิทธิภาพในพื้นที่ เพื่อให้จับผลลัพธ์ที่แม่นยำองค์ประกอบนี้ออกแบบมาให้ใช้งานได้ในรุ่นหรือเวอร์ชันที่ใช้งานจริงเพื่อเปิดใช้การทำโปรไฟล์ในเครื่อง ก่อให้เกิดความเสี่ยงต่อการเปิดเผยข้อมูลต่ำ กล่าวคือ เครื่องมือสร้างโปรไฟล์ของโฮสต์จะอ่านข้อมูลหน่วยความจำไม่ได้ และกระบวนการ Shell อ่านได้เฉพาะสแต็กเทรซเท่านั้น ซึ่งโดยทั่วไปจะมีความสับสนหรือไม่มีสัญลักษณ์ ในบิลด์ที่เผยแพร่
- API การติดตาม
android:enabled
-
ระบุว่าจะสร้างโปรไฟล์แอปพลิเคชันโดยบริการของระบบหรือเครื่องมือ Shell ได้หรือไม่
คุณต้องตั้งค่า
android:shell
สำหรับฉบับหลังด้วย หากเป็น "เท็จ" แอปพลิเคชันจะไม่สามารถสร้างโปรไฟล์ได้ ค่าเริ่มต้นคือ True แอตทริบิวต์นี้เพิ่มขึ้นใน API ระดับ 30
- เปิดตัวใน
- API ระดับ 29
<profileable>
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา 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,["# <profileable\u003e\n\nsyntax:\n:\n\n ```xml\n \u003cprofileable android:shell=[\"true\" | \"false\"] android:enabled=[\"true\" | \"false\"] /\u003e\n ```\n\ncontained in:\n: [\u003capplication\u003e](/guide/topics/manifest/application-element)\n\ndescription:\n: Specifies how profilers can access this application.\n\nattributes:\n:\n\n `android:shell`\n :\n Specifies whether the user of the device can profile this application through local debugging\n tools such as the following:\n\n - [android.os.Trace](/reference/kotlin/android/os/Trace) tracing APIs (Android 11 and lower)\n - [simpleperf](/ndk/guides/simpleperf)\n - [am profile](/studio/command-line/adb#am) commands\n - [`perfetto` profilers](/studio/command-line/perfetto) (native memory, Java memory, CPU)\n\n\n If this isn't set, or is set to `false`, these tools and APIs work only when an app is\n [debuggable](/guide/topics/manifest/application-element#debug).\n Debuggable apps incur significant and varied performance degradation and aren't useful for\n measuring timing accurately. This element is strongly recommended for local performance\n measurements, to capture accurate results.\n\n This element is designed to be usable in release, or production, builds to enable local profiling.\n It incurs minimal risk of data exposure: no memory data is readable by the host profiling tools\n and the shell process. Only stack traces are readable, which are typically obfuscated or lacking symbols\n in release builds.\n\n:\n\n `android:enabled`\n :\n Specifies whether the application can be profiled by system services or shell tools.\n For the latter, you also set [`android:shell`](#shell).\n If false, the application can't be profiled at all. The default is true.\n\n This attribute was added in API level 30.\n\nintroduced in:\n: API Level 29"]]