Appium Could not find online devices (Encountered internal error running command: Error: Could not find a connected Android device)

Hello Appium community,

I’m encountering an issue while using Appium Inspector and running mobile automation tests with Selenium in Python. Strangely, everything was working perfectly yesterday, but today, I’m facing an error that I’ve never encountered before. I would greatly appreciate your help in resolving this issue.

Here’s the error message I’m receiving:

[ADB] Using ‘adb.exe’ from ‘C:\Users\User\AppData\Local\Android\Sdk\platform-tools\adb.exe’
[debug] [ADB] Running ‘C:\Users\User\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 start-server’
[AndroidDriver] Retrieving device list
[debug] [ADB] Trying to find a connected Android device
[debug] [ADB] Getting connected devices
[debug] [ADB] Could not find online devices
[debug] [ADB] Reconnecting adb (target offline)
[debug] [ADB] Running ‘C:\Users\User\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 reconnect offline’
[debug] [ADB] Getting connected devices
[debug] [ADB] Could not find online devices
[debug] [ADB] Reconnecting adb (target offline)
[debug] [ADB] Running ‘C:\Users\User\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 reconnect offline’
[debug] [ADB] Getting connected devices
[debug] [ADB] Could not find online devices
[debug] [ADB] Reconnecting adb (target offline)

It appears that Appium is having trouble recognizing my Android device. However, when I run ‘adb devices’ separately, the device is listed as connected and online.

Could you please provide guidance on how to troubleshoot and resolve this issue? I’m using Appium with Selenium in Python, and I’ve tried the following steps:

  • Restarted the Appium server.
  • Confirmed that the USB debugging mode is enabled on my Android device.
  • Checked the ADB executable and port settings in Appium Inspector.
  • Restarted my computer.

Any insights or suggestions you can provide would be greatly appreciated. Thank you in advance!

what shows when it happen

adb devices -l
List of devices attached
ASCARLH010M60900053    device usb:36896768X product:ScarletWitch_00EEA model:Nokia_X10 device:SCW_sprout transport_id:1621
ASCARLH010M60900151    device usb:36831232X product:ScarletWitch_00EEA model:Nokia_X10 device:SCW_sprout transport_id:1618
....

show like this:

C:\Users\User>adb devices -l
List of devices attached
RR8NC07Y94Y            device product:a51nsxx model:SM_A515F device:a51 transport_id:2

and at the appium inspector show this:

Try to enable also File Transfer in USB mode on phone. No more ideas :frowning:

I have already tried doing it, but there has been no effect. :frowning:

Are you using the most recent driver version?

Yes, i used latest ADB (Android Debug Bridge version 1.0.41) and appium (2.1.3)

I mean the version of uiauomator2 driver

Windows doesn’t have a ‘which’ command, but it does have a ‘where’ command. What is the output of ‘where adb’ on the command line?

how appium installed on your computer? is it windows or mac? what java version?

Have the same problem. Appium, Windows, Android. Devices paired via Wi-Fi. All works well until the device reconnected. E. g. after I come back to the Wi-Fi zone I check adb devices (there is nothing) then adb connect (connected to 192.168.1.2:5555), then run my script and Appium fails with

  File "path\main.py", line 64, in __enter__
    self.driver = webdriver.Remote(self.appium_server_url, options=options)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "path\venv\Lib\site-packages\appium\webdriver\webdriver.py", line 229, in __init__
    super().__init__(
  File "path\venv\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 208, in __init__
    self.start_session(capabilities)
  File "path\venv\Lib\site-packages\appium\webdriver\webdriver.py", line 320, in start_session
    response = self.execute(RemoteCommand.NEW_SESSION, w3c_caps)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "path\venv\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 347, in execute
    self.error_handler.check_response(response)
  File "path\venv\Lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 229, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Could not find a connected Android device in 20000ms
Stacktrace:
UnknownError: An unknown server-side error occurred while processing the command. Original error: Could not find a connected Android device in 20000ms
    at getResponseForW3CError (/usr/lib/node_modules/appium/node_modules/@appium/base-driver/lib/protocol/errors.js:1145:9)
    at asyncHandler (/usr/lib/node_modules/appium/node_modules/@appium/base-driver/lib/protocol/protocol.js:485:57)

re-pairing solves the issue, but I think this is not the way it should work

You may try to enable the appium:suppressKillServer capability for your scenario.

1 Like

Thank you very much for the link. Could you please explain what server is it about? I can not understand the architecture. There is an Appium server on a machine which sends commands to a driver which is on a device. So, what is the ADB server? When does Appium (?) kill it? If I can use adb commands in a console, does not this mean that adb server runs?

By the way, I had 'deviceName': 'Android', in caps (which is not my device name :slight_smile:). Yesterday I removed it and today I can’t reproduce the error. :man_shrugging:

You may check Android Debug Bridge (adb)  |  Android Studio  |  Android Developers for more information about ADB architecture. uia2 driver is an ADB command line client in this scenario.

1 Like