Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
hosot opened this issue Mar 28, 2024 · 2 comments
Open
Labels
help wanted Extra attention is needed

Comments

@hosot
Copy link

hosot commented Mar 28, 2024

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 hosot added the help wanted Extra attention is needed label Mar 28, 2024
@hosot hosot changed the title Help title An error occurs when connecting adb and retrieving the device list.Help title Mar 28, 2024
@yungd1plomat
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants