D:\rnworkspace\Hello>react-native run-android
JS server already running.
Running D:\Android\sdk/platform-tools/adb -s emulator-5554 reverse tcp:8081 tcp:
8081
Building and installing the app on the device (cd android && gradlew.bat install
Debug)...
Installing APK 'app-debug.apk' on 'emulator-5554 - 6.0'
Installed on 1 device.
BUILD SUCCESSFUL
Total time: 39.532 secs
Starting the app on emulator-5554 (D:\Android\sdk/platform-tools/adb -s emulator
-5554 shell am start -n com.hello/.MainActivity)...
error: unknown host service
解决
2.查看指定端口的占用情况
C:\>netstat -aon|findstr "9050"
协议 本地地址 外部地址 状态 PID
TCP 127.0.0.1:9050 0.0.0.0:0 LISTENING 2016
P: 看到了吗,端口被进程号为2016的进程占用,继续执行下面命令: (也可以去任务管理器中查看pid对应的进程)
3.查看PID对应的进程
C:\>tasklist|findstr "2016"
映像名称 PID 会话名 会话# 内存使用
========================= ======== ================
tor.exe 2016 Console 0 16,064 K
P:很清楚吧,tor占用了你的端口。
4.结束该进程
C:\>taskkill /f /t /im tor.exe
方法2