react native启动服务进行开发调试默认端口是8081
真机开发一般通过两种方式与服务进行连接:
adb reverse tcp:8081 tcp:8081
*注意:要求android版本5.0以上
摇晃手机 ---> Dev Settings ---> debug server host & port for device
然后输入你的ip 和端口号
*在同一局域网下设置真机IP地址
但是无论那种方式都返回404异常
尝试将 http://localhost:8081/index.delta?platform=android
输入PC的浏览器中,出现了一个很有意思的现象:
localhost:8081可以正常访问,但是将localhost
换成IP就返回404
最终将react native服务的访问端口改为8089(react-native start --port=8089)成功了。
问题确认是8081端口被占用,导致只能通过localhost访问。更改端口或者将占用的结束。