Mic*_*odd 30 android adb android-sdk-tools
我最近已升级到Android SDK平台工具版本28.0.2。版本信息:
$ adb version
Android Debug Bridge version 1.0.40
Version 28.0.2-5303910
Run Code Online (Sandbox Code Playgroud)
使用adb connect
命令时,我现在得到以下错误:
$ adb connect 192.168.1.20
missing port in specification: tcp:192.168.1.20
Run Code Online (Sandbox Code Playgroud)
默认情况下,ADB以前使用TCP端口5555连接到设备。我仍然可以通过指定以下端口号连接到我的设备:
$ adb connect 192.168.1.20:5555
connected to 192.168.1.20:5555
Run Code Online (Sandbox Code Playgroud)
但是,这对我来说是一个小麻烦,因为我习惯于仅输入IP地址。有没有办法告诉此版本的ADB默认使用TCP端口5555?
Mic*_*odd 19
This bug has now been fixed as of ADB version 1.0.41, which is part of Platform Tools version 29.0.4. The fix for the bug was committed on 31st July 2019:
Restore default port for
adb connect
.The default port of 5555 was removed a while back, but the help text was never updated, and other contexts still allow a default port.
Inputting adb connect 192.168.1.20
without the trailing port number now results in ADB connecting to the target device, restoring previous behaviour.
This would appear to be a bug within ADB, introduced in December 2018 or January 2019. I believe this relates to recent changes to this else
statement in socket_spec.cpp.
} else {
std::string addr(spec.substr(4));
port_value = -1;
// FIXME: ParseNetAddress rejects port 0. This currently doesn't hurt, because listening
// on an address that isn't 'localhost' is unsupported.
if (!android::base::ParseNetAddress(addr, &hostname_value, &port_value, serial, error)) {
return false;
}
if (port_value == -1) {
*error = "missing port in specification: ";
*error += spec;
return false;
}
}
Run Code Online (Sandbox Code Playgroud)
If a port value is not specified, the variable port_value
is initialised at -1 and does not change. This value is not altered by android::base::ParseNetAddress
either. If the ParseNetAddress
check passes then we will always fall into the error-catching statement immediately afterwards.
Sid*_*rth 10
我可以通过在后缀位置添加端口号来连接我的android手机。
例如,
$ adb杀服务器
$ ADB连接192.168.1.20:5555
它直接无法连接,这给了我上面的错误。
注意:端口号是强制性的,可能您的端口号当前不同,因此请找到该端口号,然后尝试重新连接。
小智 5
$ adb kill-server
$ adb connect 192.168.1.20
Run Code Online (Sandbox Code Playgroud)
只需杀死adb服务器并正常连接即可。重新启动服务器后,将恢复默认端口(5555)。
归档时间: |
|
查看次数: |
14538 次 |
最近记录: |