运行“react-native run-android"后打包程序未启动 [英] Packager not started after running "react-native run-android"

查看:69
本文介绍了运行“react-native run-android"后打包程序未启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 React-Native 的新手.当我按照官方教程将我的应用程序部署到 Android 时,它显示一个红色屏幕,提示无法连接到开发服务器".我在物理设备上运行,所以我尝试了 adb reverse tcp:8081 tcp:8081 但问题没有解决.

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

那么是否必须保持终端打开并运行 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!

推荐答案

几年后,我仍然有这个问题.

Some years later, I still have this issue.

为我解决这个问题的是找到与项目相关的特定错误.就我而言,错误位于 Android 项目中,通过在终端中使用以下内容找到:

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

对 iOS 使用以下内容:

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.

我的问题包括特定文件中的任何构建相关问题、库出错、使用链接时错误输入的 gradle 文件.

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.

^这可能并不适用于所有人(或者可能会帮助所有类似的问题),但它对我有用并希望它会帮助其他人,因为这是我一直遇到的最烦人的 React Native 问题之一,每个日.

^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.

这篇关于运行“react-native run-android"后打包程序未启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆