android - 尝试使用 uiautomatorviewer 时无法检测 adb 版本,没有退出值
问题描述
我正在尝试使用 uiautomatorviewer 来捕获通过 USB 连接的我的 Android 设备。我已卸载 Android SDK 并重新安装。我对安装或连接等 adb 命令没有任何问题。如下所示,我可以看到带有 adb devices 命令的设备,并且在使用 adb version 命令时可以看到 adb 版本。问题是,当我启动 uiautomatorviewer 时遇到无法检测 adb 版本,adb 输出:此时没有其他任何反应,程序没有连接到我的设备。
PS C:\Windows\system32> adb devices
List of devices attached
a2738481 device
PS C:\Windows\system32> adb version
Android Debug Bridge version 1.0.41
Version 30.0.3-6597393
Installed as C:\android-sdk\platform-tools\adb.exe
PS C:\Windows\system32> uiautomatorviewer
03:55:06 E/adb: Unable to detect adb version, adb output:
Terminate batch job (Y/N)? y
PS C:\Windows\system32>
认为我的 uiautomatorviewer.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
setlocal
rem 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=%~f0
rem Change current directory and drive to where the script is, to avoid
rem issues with directories containing whitespaces.
cd /d %~dp0
rem Get the CWD as a full path with short names only (without spaces)
for %%i in ("%cd%\..") do set prog_dir=%%~fsi
rem Check we have a valid Java.exe in the path.
set java_exe=
call ..\lib\find_java.bat
if not defined java_exe goto :EOF
for /f %%a in ("%APP_HOME%\lib\uiautomatorviewer-26.0.0-dev.jar") do set jarfile=%%~nxa
set frameworkdir=.
if exist %frameworkdir%\%jarfile% goto JarFileOk
set frameworkdir=..\lib
if exist %frameworkdir%\%jarfile% goto JarFileOk
set frameworkdir=..\framework
:JarFileOk
set jarpath=%frameworkdir%\%jarfile%
if not defined ANDROID_SWT goto QueryArch
set swt_path=%ANDROID_SWT%
goto SwtDone
:QueryArch
for /f "delims=" %%a in ('%frameworkdir%\..\bin\archquery') do set swt_path=%frameworkdir%\%%a
:SwtDone
if exist "%swt_path%" goto SetPath
echo 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
set javaextdirs=%swt_path%;%frameworkdir%
call "%java_exe%" "-Djava.ext.dirs=%javaextdirs%" "-Dcom.android.uiautomator.bindir=C:\android-sdk\tools" -jar %jarpath% %*
请注意,当我在 C:\android-sdk\tools 中运行 monitor.bat 时,它可以正常工作
解决方案
-我删除并重新安装了 Android SDK -我尝试了以前的旧 SDK -尝试了 powershell 和命令提示符 -删除和添加环境变量的路径最终解决我的问题的唯一事情是重新安装 Windows。但是,嘿,至少现在它起作用了!
推荐阅读
- excel - Excel:定义一个 VBA 函数来缩短 PERCENTRANK
- java - java.lang.IllegalStateException:指定的孩子已经有一个父母。您必须先在孩子的父母上调用 removeView()
- ios - 当用户填写一些文本字段时如何更新 UILabel 的文本
- javascript - 如何在点击时传输输入值
- c# - 在不与数据表帖子重叠的范围内查找最大的 TimeSpan
- jquery - 在一个函数中返回视图和 json 数据
- yii - Yii 上是否有任何无头 CMS?
- java - Java - 附加到循环中的文件或打印整个字符串
- javascript - 如何在laravel中显示弹出警报
- google-apps-script - Google 表格脚本在共享链接中不起作用