gpt4 book ai didi

expo - 无法连接到 TCP 端口 : Connection refused when trying to open Expo app on Android Emulator in WSL2

转载 作者:行者123 更新时间:2023-12-03 17:23:15 28 4
gpt4 key购买 nike

我一直在关注本指南 https://medium.com/@pellea/using-adb-with-wsl2-7aebbb070a47到目前为止,WSL2 可以通过 Android Studios -> AVD 管理器看到在 Windows 上运行的模拟器。例如,在 Windows 和 WSL2 上,adb devices正确显示:

List of devices attached
emulator-5554 device
但是,当我进入我的博览会应用程序并尝试启动 Android 模拟器时, 我收到以下错误消息 :
Couldn't start project on Android: could not connect to TCP port 5554: Connection refused
这是在我尝试以下操作之后:
  • 导出ADB_SERVER_SOCKET=tcp:<MY IP>:5037在我的 WSL2 个人资料中
  • 通过(来自上面的链接)从我的 Windows 防火墙取消阻止 WSL2 vEthernet 连接
  • Set-NetFirewallProfile -DisabledInterfaceAliases "vEthernet (WSL)"
  • 我已经将 5554 从 Windows 转发到 WSL2,以及 5037(从 0.0.0.0 到 127.0.0.1):
  • $WSL_CLIENT = bash.exe -c "ip addr show eth0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}'";
    $WSL_CLIENT -match '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}';
    $WSL_CLIENT = $matches[0];
    iex "netsh interface portproxy add v4tov4 listenport=5554 listenaddress=127.0.0.1 connectport=5554 connectaddress=$WSL_CLIENT"
    端口如下:
    netsh interface portproxy show all

    Listen on ipv4: Connect to ipv4:

    Address Port Address Port
    --------------- ---------- --------------- ----------
    127.0.0.1 8081 172.25.38.171 8081
    0.0.0.0 5037 127.0.0.1 5037
    127.0.0.1 5554 172.29.149.0 5554

    最佳答案

    您是否尝试将端口 5554 映射到 Windows IP? (或本地主机)。 Android 模拟器运行在 Windows 上,而不是 WSL2,因此端口代理应该是从 WSL2 到 Windows,而不是向后。
    你已经用其他方式解决了吗?

    关于expo - 无法连接到 TCP 端口 : Connection refused when trying to open Expo app on Android Emulator in WSL2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64628712/

    28 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com