In UI automator viewer Error Obtaining Device scre

2019-03-12 23:19发布

When I click on UI Automator viewer --> Device screenshot throws Error Unable to connect to adb. Check if adb is installed correctly.

I am trying to run it Appium. I am able to load the apk in the emulator, stuck on the UI Automator viewer due to the adb connection error.

5条回答
地球回转人心会变
2楼-- · 2019-03-12 23:41

Open with text editor (notepad/vim) the uiautomatorviewer.bat.

Find that line:

call "%java_exe%" "-Djava.ext.dirs=%javaextdirs%" "-Dcom.android.uiautomator.bindir=%prog_dir%" -jar %jarpath% %*

and change it to call "%java_exe%" "-Djava.ext.dirs=%javaextdirs%" "-Dcom.android.uiautomator.bindir=C:\DEV\androidSDK\tools" -jar %jarpath% %*

Please notice that you should put your Tools' path after the bindir.

查看更多
我欲成王,谁敢阻挡
3楼-- · 2019-03-12 23:42

Another fix is to just copy adb.exe next to the uiautomatorviewer.bat.

If I remember correctly, modified files can confuse Android Studio when updating SDK, so you have to manually delete in order to successfully update, meaning more future proof solution. Example: link

查看更多
ら.Afraid
4楼-- · 2019-03-12 23:45

Find the following code in UIautomatorviewer

call

"%java_exe%" "-Djava.ext.dirs=%javaextdirs%" "-Dcom.android.uiautomator.bindir=%prog_dir%" -jar %jarpath% %*

Set the bindir path to adb exe. path.

Or simply paste adb.exe with uiautomatorViewer

查看更多
Luminary・发光体
5楼-- · 2019-03-12 23:47

It worked for me after I stopped Appium server and retried.

查看更多
We Are One
6楼-- · 2019-03-12 23:55

Just copy adb.exe into uiautomatorviewer.bat folder.

查看更多
登录 后发表回答