我正在使用 LDplayer4(作为 Android 模拟器),并且我正在用 python 制作一个简单的游戏宏 所以我使用 pure-python-adb 模块在 python 中控制它。
在我将文件移动到另一台电脑之前它可以工作,但在新电脑上它不起作用。
这些是我的问题:
这是我的脚本中发生错误的部分。
client = [type(0)] * emulatorcnt
adbdevice = [type(0)] * emulatorcnt
for i in range(emulatorcnt):
client[i] = AdbClient(host="127.0.0.1", port=5037)
client[i].remote_connect("localhost", ports[emulatorcnt]*2+5555))
adbdevice[i] = client[i].device("localhost:" + str(ports[emulatorcnt]*2+5555))
由于我使用 pandas 来存储端口号,因此我更改了示例代码以使其更容易理解。因此,您可能会在示例中看到错误,但这应该不是问题,因为它在其他 PC 上工作正常。
我想找出问题所在,所以我把代码改成了这样
client = AdbClient(host="127.0.0.1", port=5037)
adbdevice = client.devices())
...它工作正常,所以remote_connect似乎是问题所在。 但问题没有解决,因为我要连接20多个模拟器。
您是否尝试过将本地主机(http://127.0.0.1)更改为http://10.0.2.2/(对于Android模拟器环回)
来源:
如何在Android模拟器中连接localhost? https://developer.android.com/studio/run/emulator-networking.html