[null,null,["最后更新时间 (UTC):2025-08-21。"],[],[],null,["# Debug your Compose UI\n\nTools for debugging your Compose UI are available in Android Studio.\n\nLayout Inspector\n----------------\n\nLayout Inspector lets you inspect a Compose layout inside a running app in an\nemulator or physical device. You can use the Layout Inspector to check how often\na composable is recomposed or skipped, which can help identify issues with your\napp. For example, some coding errors might force your UI to recompose\nexcessively, which can cause [poor performance](/develop/ui/compose/performance).\nSome coding errors can prevent your UI from recomposing and, therefore,\nprevent your UI changes from showing up on the screen. If you're new to\nLayout inspector, check the [guidance](/studio/debug/layout-inspector) on how to\nrun it.\n| **Note:** If you're not seeing Compose components in layout inspector, make sure you are not removing `META-INF/androidx.compose.*.version` files from the APK. These are required for layout inspector to work.\n\n### Get recomposition counts\n\nWhen debugging your Compose layouts, knowing when composables\n[recompose](/develop/ui/compose/mental-model#recomposition) is important in\nunderstanding whether your UI is implemented properly. For example, if it's\nrecomposing too many times, your app might be doing more work than is necessary.\nOn the other hand, components that don't recompose when you anticipate them to\ncan lead to unexpected behaviors.\n\nThe Layout Inspector shows you when discrete composables in your layout\nhierarchy have either recomposed or skipped, as you interact with your app. In\nAndroid Studio, your recompositions are highlighted to help you determine\nwhere in the UI your composables are recomposing.\n\n**Figure 1.** Recompositions are highlighted in Layout Inspector.\n\nThe highlighted portion shows a gradient overlay of the composable in the image\nsection of the Layout Inspector, and gradually disappears so that you can get an\nidea of where in the UI the composable with the highest recompositions can be\nfound. If one composable is recomposing at a higher rate than another\ncomposable, then the first composable receives a stronger gradient overlay\ncolor. If you double-click a composable in the layout inspector, you're taken to\nthe corresponding code for analysis.\n| **Note:** To view recomposition counts, make sure your app is using an API level of 29 or higher, and `Compose 1.2.0` or higher. Then, deploy your app as you normally would.\n**Figure 2.**The composition and skip counter in Layout Inspector.\n\nOpen the **Layout Inspector** window and connect to your app process. In the\n**Component Tree** , there are two columns that appear next to the layout\nhierarchy. The first column shows the number of compositions for each node and\nthe second column displays the number of skips for each node. Selecting a\ncomposable node shows the dimensions and parameters of the composable, unless\nit's an inline function, in which case the parameters can't be shown. You can\nalso see similar information in the **Attributes** pane when you select a\ncomposable from the **Component Tree** or the **Layout Display**.\n\nResetting the count can help you understand recompositions or skips during a\nspecific interaction with your app. If you want to reset the count, click\n**Reset** near the top of the **Component Tree** pane.\n| **Note:** If you don't see the new columns in the **Component Tree** pane, you can view them by selecting **Show Recomposition Counts** from the **View Options** menu near the top of the **Component Tree** pane, as shown in the following image.\n\n**Figure 3**. Enable the composition and skip counter in Layout Inspector.\n\n### Compose semantics\n\nIn Compose, [Semantics](/develop/ui/compose/semantics) describe your UI in an\nalternative manner that is understandable for\n[Accessibility](/develop/ui/compose/accessibility) services and for the\n[Testing](/develop/ui/compose/testing) framework. You can use the Layout Inspector\nto inspect semantic information in your Compose layouts.\n**Figure 4.** Semantic information displayed using the Layout Inspector.\n\nWhen selecting a Compose node, use the **Attributes** pane to check whether it\ndeclares semantic information directly, merges semantics from its children, or\nboth. To quickly identify which nodes include semantics, either declared or\nmerged, use select the **View options** drop-down in the **Component Tree** pane\nand select **Highlight Semantics Layers**. This highlights only the nodes in the\ntree that include semantics, and you can use your keyboard to quickly navigate\nbetween them.\n\nCompose UI Check\n----------------\n\nTo help you build more adaptive and accessible UIs in Jetpack Compose, Android\nStudio provides a UI Check mode in Compose Preview. This feature is similar\nto [Accessibility Scanner](/guide/topics/ui/accessibility/testing#accessibility-scanner)\nfor views.\n\nWhen you activate Compose UI check mode on a Compose Preview, Android Studio\nautomatically audits your Compose UI and suggests improvements to make your UI\nmore accessible and adaptive. Android Studio checks that your UI works across\ndifferent screen sizes. In the **Problems** panel, the tool shows the issues\nthat it detects, such as text stretched on large screens or low color contrast.\n\nTo access this feature, click the UI Check icon on Compose Preview:\n**Figure 5.** Entry point to UI check mode.\n\nUI check automatically previews your UI in different configurations and\nhighlights issues found in different configurations. In the **Problems** panel,\nwhen you click an issue, you can see the details of the issue, suggested fixes,\nand the renderings that highlight the area of the issue.\n**Figure 6.** UI check mode in action."]]