React Native应用程序无法在Expo应用程序中启动 [英] React Native app does not start in Expo app
问题描述
我安装了带有Expo的HTC M8,要在其上测试用React Native编写的应用程序.我在控制台中运行我的应用程序,扫描QR码,然后尝试从智能手机连接到我的应用程序-不幸的是,我看到一条错误消息,提示它无法加载exp://myaddress:port.
I have HTC M8s with Expo installed on which I want to test my apps written in React Native. I run my app in a console, scan QR code and try to connect to my app from my smartphone - unfortunately, I see an error saying that it could not load exp://myaddress:port.
我正在使用Windows 10,并且我的PC和智能手机都连接到同一WiFi网络.
I am using Windows 10 and both my PC and my smartphone are connected to the same WiFi network.
这是ipconfig
命令的结果:
Ethernet adapter Ethernet:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . : myhostname.net
Wireless LAN adapter Wi-Fi:
Connection-specific DNS Suffix . : myhostname.guest
Link-local IPv6 Address . . . . . : fe80::8136:d112:d190:5fd8%17
IPv4 Address. . . . . . . . . . . : 10.168.4.171
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 10.168.4.1
Ethernet adapter Ethernet 6:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Wireless LAN adapter Local Area Connection* 1:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Ethernet adapter Ethernet 3:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Ethernet adapter Bluetooth Network Connection:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Tunnel adapter Local Area Connection* 11:
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::1c40:2198:f557:fb54%11
Default Gateway . . . . . . . . . :
这是运行npm start
的结果:
(...) Or enter this address in the Expo app's search bar:
exp://10.168.4.171:19000
不幸的是,我无法从智能手机中安装的Expo应用程序访问我的应用程序.
Unfortunately, I can't access my app from Expo app installed in my smartphone.
我已经尝试过:
- 我的PC上已卸载的VirtualBox
- 更改了网络适配器的优先级,以使WiFi具有最高优先级
我仍然无法通过Expo应用程序运行我的应用程序.但是,在我的PC上安装Expo app可以解决问题-它显示的QR码与控制台上显示的QR码不同,我可以运行我的react native应用,但是我想从智能手机上通过Expo app运行我的应用.
And I am still unable to run my app via Expo app. However, installing Expo app on my PC solved the problem - it shows different QR code than the one on console and I can run my react native app, but I would like to run my app from Expo app from my smartphone.
我在另一台装有Win10的PC上尝试过.安装了create-react-native-app,然后运行它,并通过WiFi完美运行.
I tried on another PC with Win10. Installed create-react-native-app, ran it and it worked perfectly through WiFi.
推荐答案
来源: Himujjal的解决方案,它可以和我一起工作: 以下步骤肯定会有所帮助.我遇到了同样的问题,并且能够在Windows 10操作系统中解决它.我在计算机上安装了Virtual Box,但无法在android expo客户端中运行CRNA.所以,
Source: https://github.com/react-community/create-react-native-app/issues/60#issuecomment-317104728 I read Himujjal's solution and it works with me: The following steps will definitely help. I had the same problem and was able to solve it in my Windows 10 OS. I had Virtual Box installed on my computer and I was not able to run CRNA in my android expo client. So,
- 首先,我通过移动热点连接了笔记本电脑.
- 然后,控制面板>(搜索网络连接")>网络连接
- 右键单击"Wifi">选择属性">"Internet协议版本4(TCP/IPv4)" [不要取消选中标记]
- 转到属性">高级...">(取消选中自动度量标准")>在(接口度量标准)下面的文本框中输入:10.
- 单击确定",然后单击确定"和确定":)
- 然后对其他"Virtual Box-xxxxx"网络执行相同的操作.而是在Interface Metric文本框中输入20.
- 单击确定",确定"和确定".
尝试在Expo上重新启动您的应用.它必须现在可以工作!
Try restarting your app on Expo. It must work now!
这篇关于React Native应用程序无法在Expo应用程序中启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!