更改 adb 服务器运行的默认端口(即 5037)

发布于 2024-09-25 15:36:22 字数 171 浏览 6 评论 0原文

我是一名初出茅庐的 Android 开发人员,如果没有简单的方法来配置 adb 服务器以在另一个端口上运行,那么工具的不灵活性将迫使我退出 Android 应用程序开发。

网络搜索没有返回任何解决方案。

我还在 android sdk 目录中的所有文件中搜索了“5037”,但没有找到那里的设置。

I am a budding android developer and if there is no easy way of configuring the adb server to run on another port then the inflexibility of the tools will force me to quit android app development.

A web search did not return any solutions.

I also searched for '5037' in all files in android sdk directory but did not find a setting there.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

离线来电— 2024-10-02 15:36:22

使用环境变量 ANDROID_ADB_SERVER_PORT 选择端口。

以下内容在 bash 下工作:

$ export ANDROID_ADB_SERVER_PORT=12345 
$ adb start-server
* daemon not running. starting it now on port 12345 *
* daemon started successfully *
$ adb devices
List of devices attached 
TA2070M5O6  device
$ ANDROID_ADB_SERVER_PORT=6789 adb devices
* daemon not running. starting it now on port 6789 *
* daemon started successfully *
List of devices attached 

在另一个终端中,我运行:

$ ANDROID_ADB_SERVER_PORT=6789 emulator ...

返回原始终端:

$ ANDROID_ADB_SERVER_PORT=6789 adb devices
List of devices attached 
emulator-5554   device
$ adb devices # ANDROID_ADB_SERVER_PORT was exported as 12345
List of devices attached 
TA2070M5O6  device

我通过 Jenkins Android 模拟器插件,因为我注意到它在不同的端口上运行 adb。

Use the environment variable ANDROID_ADB_SERVER_PORT to select the port.

The following works under bash:

$ export ANDROID_ADB_SERVER_PORT=12345 
$ adb start-server
* daemon not running. starting it now on port 12345 *
* daemon started successfully *
$ adb devices
List of devices attached 
TA2070M5O6  device
$ ANDROID_ADB_SERVER_PORT=6789 adb devices
* daemon not running. starting it now on port 6789 *
* daemon started successfully *
List of devices attached 

In another terminal I ran:

$ ANDROID_ADB_SERVER_PORT=6789 emulator ...

Back to original terminal:

$ ANDROID_ADB_SERVER_PORT=6789 adb devices
List of devices attached 
emulator-5554   device
$ adb devices # ANDROID_ADB_SERVER_PORT was exported as 12345
List of devices attached 
TA2070M5O6  device

I found this via the Jenkins Android Emulator Plugin as I noticed it was running adb on a different port.

白馒头 2024-10-02 15:36:22

对于最新的 adb 版本,

使用选项 -P (注意:Caps P)在特定端口启动 adb 服务器。

例如,尝试

$adb -P 5038 启动服务器

它将列出连接到该特定 adb 服务器的设备。如果 adb 服务器未运行,它将使用给定的端口号启动一个新的 adb 服务器。

希望它对阅读这篇文章的人有所帮助。

谢谢。

With the latest adb version,

Use option -P (Note: Caps P)to start adb server in a specific port.

For Example, Try

$adb -P 5038 start-server

It will list the devices attached to this specific adb server. If the adb server is not running then it will start a new adb server with the given port number.

Hope it helps someone reading this post.

Thanks.

岁月苍老的讽刺 2024-10-02 15:36:22

在 Windows 中,转到环境变量 – 添加一个名为 ANDROID_ADB_SERVER_PORT 的新变量
并将其设置为您想要的任何值,我已设置为 5038。

应如下所示:

为我解决了这个问题。

In Windows, go to Environment Variables – Add a new one called ANDROID_ADB_SERVER_PORT
and set it to whatever you want, I've set to 5038.

Should look like this:

Solved it for me.

白馒头 2024-10-02 15:36:22

还有另一个变量支持连接到不同机器的 adb:

ADB_SERVER_SOCKET=tcp:some.other.host:1234 adb devices

要使用它,您需要使用 -a 在另一台主机上启动 adb,并且可能也将其设置为后台:

( adb -a -P 1234 nodaemon server & ) &

There is another variable that supports this for connecting to a different machine's adb:

ADB_SERVER_SOCKET=tcp:some.other.host:1234 adb devices

To use it, you need to start adb on the other host with -a and probably background it too:

( adb -a -P 1234 nodaemon server & ) &
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文