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

踩坑: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.xdnf.cn/news/475093.html

相关文章:

  • A Neural Approach to Blind Motion Deblurring论文阅读
  • 如何安装cuda版本的pytorch
  • matlab与python问题解析
  • Flink SQL、Hudi 、Doris在数据上的组合应用
  • 深度剖析:Dify+Sanic+Vue+ECharts 搭建 Text2SQL 项目 sanic-web 的 Debug 实战
  • 【Rust闭包】rust语言闭包函数原理用法汇总与应用实战
  • 嵌入式EasyRTC音视频实时通话SDK在工业制造领域的智能巡检/AR协作等应用
  • 【Linux】Shell脚本中向文件中写日志,以及日志文件大小、数量管理
  • 小波变换+注意力机制成为nature收割机
  • 【设计模式】- 结构型模式
  • MySQL的存储过程
  • C语言进阶-数组和函数
  • 青少年编程与数学 02-019 Rust 编程基础 15课题、错误处理
  • Python连接redis
  • XML简要介绍
  • 模拟jenkins+k8s自动化部署
  • 济南超算研究所面试问题
  • MAX6749KA-T硬件看门狗调试
  • 医学影像系统性能优化与调试技术:深度剖析与实践指南
  • 一台入网的电脑有6要素, 机器名,mac,ip,俺码,网关,dns,分别有什么作用
  • ReinboT:通过强化学习增强机器人视觉-语言操控能力
  • 微信小程序:封装request请求、解决请求路径问题
  • Vue3 加快页面加载速度 使用CDN外部库的加载 提升页面打开速度 服务器分发
  • 云计算与大数据进阶 | 26、解锁云架构核心:深度解析可扩展数据库的5大策略与挑战(上)
  • Kubernetes 1.28 无 Docker 运行时环境下的容器化构建实践:Kaniko + Jenkins 全链路详解
  • 学习threejs,使用Physijs物理引擎,各种constraint约束限制
  • 分布式锁: Redisson 实现分布式锁的原理与技术细节
  • 前端下载ZIP包方法总结
  • 前端取经路——量子UI:响应式交互新范式
  • 第二天的尝试