问题描述
我关注了这个
让我们一步一步来:
确保包服务器正在运行.从截图中,您可以看到我输入的命令react-native run-android"和响应启动JS服务器..."
确保您的设备已连接... 是的,Vysor 看到了我的设备.我们看到 Vysor 在屏幕截图中显示了正在运行的应用.
...USB 已启用 是的,应用正在运行,这就是我们看到红色错误屏幕的原因,但应用仍在运行.
运行adb reverse tcp:8081 tcp:8081" 是的,截图显示我运行了命令.
设备和端口... 是的,也是.看下一张截图
我还做错了什么?我怎样才能让它工作?
- 在一个控制台窗口中运行
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:
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..."
Ensure your device is connected... Yes, Vysor sees my device. Wee see Vysor showing the app running in the screenshot.
...USB enabled Yes, the app is running, that's why we see the red error screen, but it's the app running nevertheless.
Run "adb reverse tcp:8081 tcp:8081" Yes, the screenshot shows that I ran the command.
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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!