AdvancedSharpAdbClient icon indicating copy to clipboard operation
AdvancedSharpAdbClient copied to clipboard

An error occurs when connecting adb and retrieving the device list.Help title

Open hosot opened this issue 10 months ago • 2 comments

What can we do for you?

if (!AdbServer.Instance.GetStatus().IsRunning)
{
    AdbServer server = new AdbServer();
    try
    {
        StartServerResult result = server.StartServer(Application.StartupPath + @"\adb\adb.exe", false);
        if (result != StartServerResult.Started)
        {
            MessageBox.Show("adb fail", "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            return;
        }
        else
        {
            MessageBox.Show("adb OK!", "info", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
    }
    catch (Exception ex)
    {
        **MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);**
        return;
    }
}

The error occurs in the highlighted part. Exception: The adb process returnd error code -1 when running command start-server

try
{
    adbClient = new AdbClient();

}
catch (Exception ex)
{ MessageBox.Show(ex.Message, "1"); return; }
try
{
    var devices = adbClient.GetDevices();

    if (devices.Count() == 0)
    {
        MessageBox.Show("No Devices");
        return;
    }
    try
    {
        deviceData = devices.FirstOrDefault();

    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message, "3");
        return;
    }
}
catch (Exception ex)
{
    **MessageBox.Show(ex.Message, "2");**
    return;
}

In the highlighted part 'adb cannot connect to 127.0.0.1:5037: The connection failed because the target computer refused the connection.' An error occurs.

It works normally on my development PC, but a problem has occurred on the PC where I need to use the program, so I can't use it.

In this case, are there any additional programs that I need to install?

hosot avatar Mar 28 '24 06:03 hosot

https://learn.microsoft.com/en-us/answers/questions/788883/cannot-connect-to-127-0-0-1-58526-(port-shown-unde

wherewhere avatar Mar 28 '24 18:03 wherewhere

Check if the path to adb.exe is correct, it should not contain Cyrillic, spaces or any other characters

yungd1plomat avatar Mar 28 '24 18:03 yungd1plomat