- 語法:
<profileable android:shell=["true" | "false"] android:enabled=["true" | "false"] />
- 包含於:
<application>
- 說明:
- 指定分析器如何存取這個應用程式。
- 屬性:
android:shell
-
指定裝置使用者是否能透過本機偵錯方式剖析這個應用程式
工具,例如:
android.os.Trace
追蹤 API (Android 11 以下版本)simpleperf
am profile
指令perfetto
分析器 (原生記憶體、Java 記憶體、CPU)
false
,這些工具和 API 就只會在應用程式處於以下狀態時運作debuggable
。 可進行偵錯的應用程式會造成各種效能明顯降低的問題,不適用於 準確評估時機為維持本機效能,強烈建議您使用此元素 以獲得準確結果這個元素的設計宗旨是在發布版本/正式版本中都要能夠使用,這樣才能啟用本機剖析。 這會使資料外洩的風險降到最低,因為主機剖析工具無法讀取任何記憶體資料 和殼層程序只有堆疊追蹤可供讀取。堆疊追蹤通常經過模糊處理或缺少符號 推出新版本
android:enabled
-
指定系統服務或殼層工具是否能剖析應用程式。
如果是後者,您還要設定
android:shell
。 如果為 false,則完全無法剖析應用程式。預設值為 true。 這項屬性於 API 級別 30 中新增。
- 導入版本:
- API 級別 29
<個人檔案>
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。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,["# <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"]]