You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

Android SDK Tools中uiautomatorviewer.bat无法运行,求助解决办法

Fixing uiautomatorviewer.bat Not Launching on Newer Systems

Hey there, let’s work through this uiautomatorviewer issue— I’ve run into this exact problem with newer Windows systems too! The root cause is that uiautomatorviewer is a legacy Android SDK tool that doesn’t play nice with modern JDK versions (9 and above), since they removed some deprecated modules the tool relies on. You mentioned modifying the last line of the .bat file before, so let’s expand on that with reliable fixes:

Step-by-Step Modification Guide

  1. Find the batch file: Navigate to <your-android-sdk-folder>/tools/bin/uiautomatorviewer.bat
  2. Open it in a text editor: Use something like Notepad++ or VS Code (avoid basic Notepad if you can, it handles line endings better)
  3. Locate the final execution line: It usually starts with call %java_exe% and references the tool’s JAR file
  4. Update the line to fix compatibility:
    • If you’re using JDK 9+, add the missing module flag to the command:
      call %java_exe% -Djava.ext.dirs=%java_ext_dirs% --add-modules java.xml.bind -jar %jar_path% %*
      
    • If you have JDK 8 installed (the most compatible version for this tool), you can force it to use that specific JDK by hardcoding the path:
      call "C:\Program Files\Java\jdk1.8.0_301\bin\java.exe" -Djava.ext.dirs=%java_ext_dirs% -jar %jar_path% %*
      
      Just replace the path with your actual JDK 8 installation location.

Quick Additional Checks

  • Double-check that your Android SDK Tools folder is intact (no missing files from accidental deletions)
  • If you set a JAVA_HOME environment variable, make sure it points to a compatible JDK version if you’re relying on the system’s default Java
  • If you still see errors, look at the command prompt output— it’ll usually tell you exactly which module or class is missing, which can help tweak the fix further

Heads up: uiautomatorviewer has been officially deprecated. For modern Android projects, Google recommends using Layout Inspector (built right into Android Studio) or UiAutomator 2.0 with AndroidX test libraries. But if you need the old tool for legacy work, the above fixes should get it running again.

内容的提问来源于stack exchange,提问作者Serg Buch

火山引擎 最新活动