ADB 反向套接字连接到 Android Studio 上的两个或多个模拟器/设备

发布于 2025-01-16 21:52:10 字数 689 浏览 1 评论 0原文

我正在使用 Firebase 模拟器来测试我的 Android 应用程序。我正在尝试设置一个测试环境,其中 Android 模拟器(AVD 管理器设备)和 Android 真实设备可以访问在 http://localhost:4000 上找到的 Firebase 模拟器实时数据库。

我可以使两个(真实和虚拟)设备单独都可以访问 Firebase 模拟器数据库,但不能同时访问这两个设备。

我的真实设备通过 USB 端口连接,并允许 USB 调试和我的 Android 模拟器同时运行。然后,在 Android Studio platform-tools 文件夹中,我打开一个命令窗口并输入以下内容:

adb reverse tcp:4000 tcp:4000

这给了我一个错误:adb.exe:错误:多个设备/模拟器< /em>

在 Firebase 模拟器项目中找到的 firebase.json 文件中,我对数据库连接进行了以下设置:

"database": {
  "host": "localhost",
  "port": 9000
},

如何使两个(真实和虚拟)设备或两个(虚拟)设备连接到Firebase 模拟器实时数据基地?

I am using Firebase emulators to test my Android app. I'm trying to set up a testing environment where an Android emulator(AVD manager device) AND an android real device have access to my Firebase emulator real time database found on http://localhost:4000.

I can make both(real and virtual) devices, individually, have access to the Firebase emulator database, but NOT both at the same time.

I have my real device connected via USB port and allowed USB debugging and my Android emulator running at the same time. Then, on the Android Studio platform-tools folder I opened up a command window and input the following:

adb reverse tcp:4000 tcp:4000

This gives me an error: adb.exe: error: more than one device/emulator

Inside my firebase.json file found inside my Firebase emulator project I have the following set-up for connections to my database:

"database": {
  "host": "localhost",
  "port": 9000
},

How can I make both (REAL and VIRTUAL) devices or two (Virtual) devices connect to Firebase emulator Real Time data base?

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

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

发布评论

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

评论(2

一枫情书 2025-01-23 21:52:10

如果您有其中之一(模拟器、设备),则应指定设备序列号

adb -s serialno reverse tcp:4000 tcp:4000

-d-e

此外,要以交互方式选择设备,您可以使用以下要点: https://gist.github.com/dtmilano /4537110

You should specify the device serialno

adb -s serialno reverse tcp:4000 tcp:4000

or, -d and -e if you have one of each (emulator, device).

Additionally, to select the device interactively you can use this gist: https://gist.github.com/dtmilano/4537110

佞臣 2025-01-23 21:52:10

感谢迭戈·托雷斯·米兰诺为我指明了正确的方向。

使用命令:adb -s serialno 反向 tcp:4000 tcp:4000 就可以了!

但是您必须首先运行命令
adb devices

运行此命令后,您将获得 ADB 所连接的所有设备的所有序列号。然后,只需运行:
adb -s serialno 反向 tcp:4000 tcp:4000 使用您所需的设备/模拟器。它适用于真实设备或模拟器!

Thank you Diego Torres Milano for pointing me in the right direction.

using the command: adb -s serialno reverse tcp:4000 tcp:4000 will work!

HOWEVER you must FIRST run the command
adb devices

Once you run this command, you get all the serial no's of all the connected devices you have to ADB. Then, just run:
adb -s serialno reverse tcp:4000 tcp:4000 using your desired device/emulator. It works for either real device or emulator!

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