Can only update react native on emulator, not physical device

老子叫甜甜 提交于 2019-12-02 05:44:50

问题


I have an app working on a local emulator that is updating live and doing all the things it should be doing.

I also have a physical device connected via USB, and deploying to the device through 'run-android' works successfully, so the bridge is working.

However, the app only shows the default react native welcome screen. Any attempt to update the app results in "Could not connect to development server".

I have tried the suggestions on the screen and they aren't helping. Where do I go next?


回答1:


You probably actually can't talk to the dev server. On an emulator a virtual network with the host PC is automatic, on a real there's no virtual network set up between it and the device. You need to actually have an open port on your desktop for it, and hit the right IP on your physical device, with the wifi network (I'm assuming they're on the same wifi network) set to allow requests to your PC.

Or turn dev support off and include the bundle file in your app. Then you're not going to hotload code, but you have a static version ready to go without a server to talk to.




回答2:


I tried this and it solved my problem.

react-native start --reset-cache

and then

react-native run-android


来源:https://stackoverflow.com/questions/52320806/can-only-update-react-native-on-emulator-not-physical-device

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!