Skip to content

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

@hosot

Description

@hosot

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions