当前位置: 首页 > article >正文

踩坑:uiautomatorviewer.bat 打不开

错误信息

运行 sdk\tools\bin\uiautomatorviewer.bat 报错

-Djava.ext.dirs=..\lib\x86_64;..\lib is not supported. Use -classpath instead. Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit.

原因 

java版本和bat需要的不匹配,bat应该是需要1.8版本的。

解决办法

1. 使用1.8版本的java,每次使用之前修改环境变量。--不推荐,每次都要切换环境

Linux上切换环境比较方便,但是我在Windows上尝试了 还是不行。下面推荐更简单的方法

2. 只需要修改bat脚本能支持最新的java环境即可,这样就不用每次切换环境了。--强烈推荐

修改后亲测可用的bat脚本如下:

@echo off
rem Copyright (C) 2012 The Android Open Source Project
rem
rem Licensed under the Apache License, Version 2.0 (the "License");
rem you may not use this file except in compliance with the License.
rem You may obtain a copy of the License at
rem
rem      http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.rem don't modify the caller's environment
setlocalrem Set up prog to be the path of this script, including following symlinks,
rem and set up progdir to be the fully-qualified pathname of its directory.
set prog=%~f0rem Change current directory and drive to where the script is, to avoid
rem issues with directories containing whitespaces.
cd /d %~dp0rem Get the CWD as a full path with short names only (without spaces)
for %%i in ("%cd%\..") do set prog_dir=%%~fsirem Check we have a valid Java.exe in the path.
set java_exe=
call ..\lib\find_java.bat
if not defined java_exe goto :EOFfor /f %%a in ("%APP_HOME%\lib\uiautomatorviewer-26.0.0-dev.jar") do set jarfile=%%~nxa
set frameworkdir=.if exist %frameworkdir%\%jarfile% goto JarFileOkset frameworkdir=..\libif exist %frameworkdir%\%jarfile% goto JarFileOkset frameworkdir=..\framework:JarFileOkset jarpath=%frameworkdir%\%jarfile%if not defined ANDROID_SWT goto QueryArchset swt_path=%ANDROID_SWT%goto SwtDone:QueryArchfor /f "delims=" %%a in ('%frameworkdir%\..\bin\archquery') do set swt_path=%frameworkdir%\%%a:SwtDoneif exist "%swt_path%" goto SetPathecho SWT folder '%swt_path%' does not exist.echo Please set ANDROID_SWT to point to the folder containing swt.jar for your platform.exit /B:SetPath
@REM set javaextdirs=%swt_path%;%frameworkdir%
set "CLASSPATH=%swt_path%\*;%frameworkdir%\*"@REM call "%java_exe%" "-Djava.ext.dirs=%javaextdirs%" "-Dcom.android.uiautomator.bindir=%prog_dir%" -jar %jarpath% %*rem Launch app using -classpath (not -Djava.ext.dirs)
call "%java_exe%" -classpath "%CLASSPATH%" -Dcom.android.uiautomator.bindir=%prog_dir% com.android.uiautomator.UiAutomatorViewer %*

3. 其他平台也类似,只需要把脚本语法修改正确即可。 

http://www.lryc.cn/news/2379221.html

相关文章:

  • Atcoder Beginner Contest 406
  • 记录一次win11本地部署deepseek的过程
  • 嵌入式STM32学习——外部中断EXTI与NVIC的基础练习⭐
  • 进程状态并详解S和D状态
  • 数据获取_Python
  • <前端小白> 前端网页知识点总结
  • 历史数据分析——宁波海运
  • 小结:jvm 类加载过程
  • OpenCv高阶(八)——摄像头调用、摄像头OCR
  • Java开发经验——阿里巴巴编码规范实践解析3
  • MySQL——6、内置函数
  • MySQL如何查看某个表所占空间大小?(表空间大小查看方法)
  • 软件架构之-论软件系统架构评估以及应用
  • 低延迟与高性能的技术优势解析:SmartPlayer VS VLC Media Player
  • pytorch小记(十九):深入理解 PyTorch 的 `torch.randint()` 与 `.long()` 转换
  • 深入解析Spring Boot与微服务架构:从入门到实践
  • 【交互 / 差分约束】
  • 宝塔面板部署前后端项目SpringBoot+Vue2
  • 现代生活健康养生新视角
  • 鸿蒙Next API17新特性学习之如何使用新增鼠标轴事件
  • 多模态大语言模型arxiv论文略读(八十一)
  • 3.4/Q2,Charls最新文章解读
  • 通过觅思文档项目实现Obsidian文章浏览器在线访问
  • Python列表全面解析:从入门到精通
  • 5月18总结
  • 赋予AI更强的“思考”能力
  • Linux Bash | Capture Output / Recall
  • 2025/5/18
  • 基于Quicker构建从截图到公网图像链接获取的自动化流程
  • LeetCode算 法 实 战 - - - 双 指 针 与 移 除 元 素、快 慢 指 针 与 删 除 有 序 数 组 中 的 重 复 项