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.
Open with text editor (notepad/vim) the uiautomatorviewer.bat.
Find that line:
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.
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
Find the following code in UIautomatorviewer
call
Set the bindir path to adb exe. path.
Or simply paste
adb.exe
with uiautomatorViewerIt worked for me after I stopped Appium server and retried.
Just copy
adb.exe
intouiautomatorviewer.bat
folder.