在设备上运行 React Native Android [英] Running React Native Android on device

查看:53
本文介绍了在设备上运行 React Native Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我关注了这个

让我们一步一步来:

  1. 确保包服务器正在运行.从截图中,您可以看到我输入的命令react-native run-android"和响应启动JS服务器..."

  2. 确保您的设备已连接... 是的,Vysor 看到了我的设备.我们看到 Vysor 在屏幕截图中显示了正在运行的应用.

  3. ...USB 已启用 是的,应用正在运行,这就是我们看到红色错误屏幕的原因,但应用仍在运行.

  4. 运行adb reverse tcp:8081 tcp:8081" 是的,截图显示我运行了命令.

  5. 设备和端口... 是的,也是.看下一张截图

我还做错了什么?我怎样才能让它工作?

解决方案

  • 在一个控制台窗口中运行 npm run start 以启动 react-native 开发服务器.
  • 然后打开一个单独的控制台窗口来运行 react-native run-android.

如果我不在单独的控制台窗口中启动开发服务器,我有时会遇到问题.

进一步说明:

  • 如果您在控制台中运行 $ adb devices,请确保显示您的设备.
  • 请注意,adb reverse tcp:8081 tcp:8081 仅适用于 Android 5.0 及更高版本.

I followed this official help page and also consulted this previous SO question.

But I still don't know what is wrong here.

Let's take step by step:

  1. Ensure the package server is running. From the screenshot, you can see the command I typed "react-native run-android" and the reponse "Starting JS server..."

  2. Ensure your device is connected... Yes, Vysor sees my device. Wee see Vysor showing the app running in the screenshot.

  3. ...USB enabled Yes, the app is running, that's why we see the red error screen, but it's the app running nevertheless.

  4. Run "adb reverse tcp:8081 tcp:8081" Yes, the screenshot shows that I ran the command.

  5. Device and port... Yes, did that too. See next screenshot

What am I still doing wrong? How can I make it work?

解决方案

  • Run npm run start in one console window to start the react-native development server.
  • Then open a separate console window to run react-native run-android.

I sometimes ran into problems if I don't start the development server in a separate console window.

Further notes:

  • Make sure that your device is shown if you run $ adb devices in your console.
  • Note that adb reverse tcp:8081 tcp:8081 only works for Android versions 5.0 and up.

这篇关于在设备上运行 React Native Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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