Packager not started after running “react-native run-android”

心已入冬 提交于 2020-01-02 11:27:14

问题


I am new to React-Native. When I am following the official tutorial to deploy my app to Android, it show a red screen saying that "Could not connect to development server". I am running on a physical device so I tried adb reverse tcp:8081 tcp:8081 but the problem was not solved.

I googled around and found that I have to run:

react-native start

So is it a must to keep a terminal opened and running react-native start? Because this is not documented in official tutorials and I even don't know why it works!


回答1:


I had also recently faced this issue in Android for around 3 days. Luckily some random blog helped me out.

To solve this issue, you must shake your device and open the developer menu. Press Dev Settings. Then "debug server host & port for device", enter the IP address of the system from which you launched this app along with port :8081.

Like 172.21.217.56:8081

Shake the device again and reload. The app should work then. Hope that helps you.




回答2:


Some years later, I still have this issue.

What solved this for me is to find the specific error related to the project. In my case, the error located in the Android project, found by using the following in the terminal:

react-native run-android

Use the following for iOS:

react-native run-ios

By running the above in a terminal window, the projects will try to be built and therefore errors should be shown.

My issues range from any build related issues in a specific file, to libraries going wrong, to gradle files being wrongly inputted when using linking.

^This may not work for all (or maybe will help all similar issues), but it worked for me and hope it will help others as this is one of the most annoying React Native issues I have all the time, once per day.



来源:https://stackoverflow.com/questions/42141646/packager-not-started-after-running-react-native-run-android

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