Unable to get items in uiautomator tool when application is running on device

I have a setting in which a web application on my PC gets access to information about the application running on the connected device (via USB debugging). and continuously sends application data to a web application (PC).

I automate this using selenium (web GUI) and appium (device) to test automation.

Problem. I cannot connect to the device using the uiautomator.bat tool after the application is launched on the device and communicates with the web application (on my PC). Getting the error below. Is there a workaround for this problem.

-------- uiautomator.bat magazine -----------

C: \ Users \ sat_yug \ android-SDKs \ tools> uiautomatorviewer.bat 03:57:35 E / DeviceMonitor: Adb connection error: existing connection was forcibly closed by the remote host 03:57:36 E / DeviceMonitor: connection attempts: 1 03 : 57: 38 E / DeviceMonitor: connection attempts: 2 03:57:40 E / DeviceMonitor: connection attempts: 3 03:57:42 E / DeviceMonitor: connection attempts: 3 03:57:44 E / DeviceMonitor: connection attempts: 5 03:58:04 E / DeviceMonitor: Adb connection error: existing connection was forcibly closed by the remote host

------------ adb device log ---------------------

C: \ Users \ sat_yug \ android-sdks \ platform-tools> adb devices List of connected devices The adb server is out of date. killing ... Error: could not install smartsocket listener: cannot bind to 127.0.0.1:5037: only one use of each socket address (protocol / n network address / port). (10048) could not read ok from the ADB server * could not start the daemon * Error: cannot connect to the daemon


+5
source share
3 answers

I just decided it for me, so I thought I would share it, although the question is old. Just restarting adb will not work. Open a command prompt with administrator privileges and do the following:

netstat -o -n -a | findstr 5037 

This will result in a list of results. This is what was in my case:

  TCP 127.0.0.1:5037 0.0.0.0:0 LISTENING 3408 TCP 127.0.0.1:5037 127.0.0.1:50018 ESTABLISHED 3408 TCP 127.0.0.1:5037 127.0.0.1:54507 ESTABLISHED 3408 TCP 127.0.0.1:5037 127.0.0.1:63330 ESTABLISHED 3408 TCP 127.0.0.1:5037 127.0.0.1:63332 ESTABLISHED 3408 TCP 127.0.0.1:50018 127.0.0.1:5037 ESTABLISHED 1664 TCP 127.0.0.1:54507 127.0.0.1:5037 ESTABLISHED 1664 TCP 127.0.0.1:63330 127.0.0.1:5037 ESTABLISHED 1664 TCP 127.0.0.1:63332 127.0.0.1:5037 ESTABLISHED 1664 

In the rightmost column is the process identifier (PID). The process that listens for the required socket is 3408. Therefore, this process must DIE ! What happens if you do this:

 taskkill /F /PID 3408 

After that you can do

 adb kill-server adb start-server 

to restart the adb server, and it is most likely that your adb will start successfully.

UPDATE:

I made this little bat file to make it easier as it happens quite often. Make sure that

 1. to place this bat at the same folder as adb.exe 2. run it as administrator. 

It will immediately show you the PID that uses the socket. Enter the PID and press Enter and the problem goes away.

 netstat -o -n -a | findstr 5037 | findstr LISTENING set /p pid=Enter pid to kill:%=% @echo %pid% taskkill /F /PID %pid% adb kill-server adb start-server pause 
+11
source

According to the answer to the IT question, there is a possibility that you may have two versions of adb installed.

Try the following (quoted from a single post to check if there are multiple versions) and get rid of the unwanted.

where adb.exe

Another option you can try is to kill and start the adb server until the error occurs or at the beginning of the execution of your batch file.

 adb kill-server adb start-server .... .... //your script here .... .... 
+1
source

I had the same problem. Decision:

Enter the adb shell from 1 machine and run

 adb start-server 

and now try connecting from another computer to the same device, and you can connect successfully!

In my case, 2 connections were: USB and Wi-Fi.

0
source

Source: https://habr.com/ru/post/1238622/


All Articles