You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用UI Automator View捕获快照时解析UI层级XML文件报错求助

Fixes for "Error while parsing UI hierarchy XML file: Invalid ui automator hierarchy file" in UI Automator View

Hey there, sorry to hear you're hitting this frustrating error when trying to capture a screen snapshot with UI Automator View. Restarting the device didn't cut it, so let's dive into some targeted fixes that have resolved this issue for other developers:

  • Check version compatibility between UI Automator and your device's Android OS
    Mismatched versions often cause parsing errors. For example, if your device runs Android 12 or later, make sure you're using the UI Automator tool from a matching (or latest) Android SDK Platform Tools package. You can verify your installed SDK targets with the command:

    android list target
    

    Ensure the target version aligns with your device's Android version.

  • Clear UI Automator-related cache and data
    Corrupted cached files on either the device or your computer might be the culprit:

    • On your device: Go to Settings > Apps > Show system apps, locate services like UI Automator Server or Accessibility Scanner (names vary by device), then clear their cache and data.
    • On your computer: Close UI Automator View, navigate to your user directory's .android folder, delete any temporary UI Automator cache files, then restart the tool.
  • Reset your ADB connection
    Flaky ADB links can mess up the XML hierarchy transfer. Try these steps:

    1. Run adb kill-server in your terminal to shut down the ADB service.
    2. Follow it with adb start-server to restart the service.
    3. Confirm your device is recognized with adb devices before trying to capture the snapshot again.
  • Capture a specific app's interface instead of the full system screen
    System UI elements (like custom status bars or navigation controls) sometimes introduce invalid XML nodes. Open the app you want to inspect first, then use UI Automator View to capture just that app's screen—this avoids parsing system-level elements that might be causing the error.

  • Verify accessibility permissions
    UI Automator relies on accessibility services to pull the UI hierarchy. Head to Settings > Accessibility on your device, find the UI Automator-related service, and make sure its permissions are enabled.

  • Test with the command-line UI Automator dump
    If the GUI tool is failing, use the command line to isolate the issue:

    1. Run adb shell uiautomator dump /sdcard/ui_dump.xml on your device to generate the hierarchy XML.
    2. Pull the file to your computer with adb pull /sdcard/ui_dump.xml.
    3. Open the XML file in a text editor—if it's malformed, the problem is on the device side; if it looks valid, the issue lies with the UI Automator View tool itself (try reinstalling the SDK Platform Tools).

内容的提问来源于stack exchange,提问作者Nidhin Kumar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 08:19:24