Getting "error: closed" twice on "adb reverse"
Getting "error: closed" twice on "adb reverse"
我正在尝试通过 ADB 反向转发端口,但它只是 returns error: closed
的神秘错误。正常转发工作。会话片段:
$ adb forward tcp:59778 tcp:59778
$ adb forward --list
015d2109ce0c1a0f tcp:59778 tcp:59778
$ adb forward --remove-all
$ adb forward --list
$ adb reverse --list
error: closed
error: closed
$ adb reverse tcp:59778 tcp:59778
error: closed
error: closed
我正在通过 USB 连接到非根 Nexus 7 2012 Android 4.4.4 来自 Windows 7 Pro x64 on Boot Camp。
adb reverse
是在 Android 5.0
中引入的
仔细执行这些步骤。
注意:所有命令只需要 运行 在一个项目中。
运行 先这条命令:
npm react-native start
在同一个项目中打开另一个window并且运行:
curl "http://localhost:8081/index.android.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"
这将在资产文件夹中创建 index.android.bundle
运行:
npm react-native run-android
现在您可以在构建文件夹中获取 apk,这将正常工作。
adb reverse 的原因在 android 之前 5 你可以适当地使用 adb forward 和一个服务监听 android 并通过这个入站连接隧道连接其他连接。我主要使用 ssh 来执行此操作,但您需要 android 上的 ssh 服务器。您可以使用 ssh -R incommingreverseportonandroid:hostyouwanttoforwardto:portyouwanttoforwardto sshuseronandroid@localhost -p portyouhaveusedforadbforwaqrdtoaccessandroidssshserver
进行连接
但我不知道如何在 android 上启用 ssh 服务器,也许有更好的方法,因为 ssh 使用加密,这在 usb 上是不需要的,并且用完了 cpu。
当我被迫落后于国家时,我正在使用这种方式与我的服务器共享服务...
希望有人能找到一种方法将这种理论上的方法变为现实的可能性
由于 Android 低于 5.0 的版本不支持 adb reverse
,您需要使用其他方法,例如通过 Wi-Fi 连接。如果您使用的是 React Native,Facebook 已添加 official documentation to connect to the development server via Wi-Fi。引用 MacOS 的说明,但他们也有 Linux 和 Windows:
Method 2: Connect via Wi-Fi
You can also connect to the development server over Wi-Fi. You'll first need to install the app on your device using a USB cable, but once that has been done you can debug wirelessly by following these instructions. You'll need your development machine's current IP address before proceeding.
You can find the IP address in System Preferences → Network.
Make sure your laptop and your phone are on the same Wi-Fi network.
Open your React Native app on your device.
You'll see a red screen with an error. This is OK. The following steps will fix that.
Open the in-app Developer menu.
Go to Dev Settings → Debug server host for device.
Type in your machine's IP address and the port of the local dev server (e.g. 10.0.1.1:8081).
Go back to the Developer menu and select Reload JS.
adb reverse
需要 Android 5.0+。对于之前的设备,您需要使用类似的解决方法。
如果您的 Android 设备上安装了 busybox(大多数 Genymotion 图像都安装了),您可以使用此咒语模拟 adb reverse
:
adb shell busybox nc -ll -p {guest port} -e busybox nc {host IP} {host port}
本例中"guest"是模拟器中的AndroidOS运行"host"是电脑运行模拟器.
只需使用 10.0.2.2 而不是 localhost/127.0.0.1 作为您的主机名。它将直接尝试连接到主机上的端口(与反向影响相同)。
我正在尝试通过 ADB 反向转发端口,但它只是 returns error: closed
的神秘错误。正常转发工作。会话片段:
$ adb forward tcp:59778 tcp:59778
$ adb forward --list
015d2109ce0c1a0f tcp:59778 tcp:59778
$ adb forward --remove-all
$ adb forward --list
$ adb reverse --list
error: closed
error: closed
$ adb reverse tcp:59778 tcp:59778
error: closed
error: closed
我正在通过 USB 连接到非根 Nexus 7 2012 Android 4.4.4 来自 Windows 7 Pro x64 on Boot Camp。
adb reverse
是在 Android 5.0
仔细执行这些步骤。
注意:所有命令只需要 运行 在一个项目中。
运行 先这条命令:
npm react-native start
在同一个项目中打开另一个window并且运行:
curl "http://localhost:8081/index.android.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"
这将在资产文件夹中创建
index.android.bundle
运行:
npm react-native run-android
现在您可以在构建文件夹中获取 apk,这将正常工作。
adb reverse 的原因在 android 之前 5 你可以适当地使用 adb forward 和一个服务监听 android 并通过这个入站连接隧道连接其他连接。我主要使用 ssh 来执行此操作,但您需要 android 上的 ssh 服务器。您可以使用 ssh -R incommingreverseportonandroid:hostyouwanttoforwardto:portyouwanttoforwardto sshuseronandroid@localhost -p portyouhaveusedforadbforwaqrdtoaccessandroidssshserver
进行连接但我不知道如何在 android 上启用 ssh 服务器,也许有更好的方法,因为 ssh 使用加密,这在 usb 上是不需要的,并且用完了 cpu。
当我被迫落后于国家时,我正在使用这种方式与我的服务器共享服务...
希望有人能找到一种方法将这种理论上的方法变为现实的可能性
由于 Android 低于 5.0 的版本不支持 adb reverse
,您需要使用其他方法,例如通过 Wi-Fi 连接。如果您使用的是 React Native,Facebook 已添加 official documentation to connect to the development server via Wi-Fi。引用 MacOS 的说明,但他们也有 Linux 和 Windows:
Method 2: Connect via Wi-Fi
You can also connect to the development server over Wi-Fi. You'll first need to install the app on your device using a USB cable, but once that has been done you can debug wirelessly by following these instructions. You'll need your development machine's current IP address before proceeding.
You can find the IP address in System Preferences → Network.
Make sure your laptop and your phone are on the same Wi-Fi network. Open your React Native app on your device. You'll see a red screen with an error. This is OK. The following steps will fix that. Open the in-app Developer menu. Go to Dev Settings → Debug server host for device. Type in your machine's IP address and the port of the local dev server (e.g. 10.0.1.1:8081). Go back to the Developer menu and select Reload JS.
adb reverse
需要 Android 5.0+。对于之前的设备,您需要使用类似的解决方法。
如果您的 Android 设备上安装了 busybox(大多数 Genymotion 图像都安装了),您可以使用此咒语模拟 adb reverse
:
adb shell busybox nc -ll -p {guest port} -e busybox nc {host IP} {host port}
本例中"guest"是模拟器中的AndroidOS运行"host"是电脑运行模拟器.
只需使用 10.0.2.2 而不是 localhost/127.0.0.1 作为您的主机名。它将直接尝试连接到主机上的端口(与反向影响相同)。