Nie*_*eck 0 android node.js ios reactjs react-native
I'm trying to run an app inside my Android emulator and on my Iphone using Expo and Create React Native App.
I' ve ran the following commands to do this.
create-react-native-app MyFirstApp
npm run android
Run Code Online (Sandbox Code Playgroud)
After doing the run command the app runs in the emulator with the following error:
Something went wrong! Could not load *ip*. Network response timed out.
Uncaught error: java.net.SocketTimeoutException: connect timed out.
Run Code Online (Sandbox Code Playgroud)
The same thing happens when I scan the QR code on my Iphone and I can't reach the ip in my web browser.
I've found the following fixes on internet but nothing seems to work:
Edit:
I installed Expo XDE to start the server. It works fine when I use a tunnel but that option is extremely slow when reloading changes. It still doesn't work with localhost or LAN. Is it possible that I have to use something like port forwarding to open this port on my router?
Also: When I typ: localhost:19000 in Google Chrome I get some Json returned. But this doesn't work when I'm in Expo!
解决了问题!我刚刚找到以下解决方案:
转到cmd并输入ipconfig
获取虚拟机的ip4地址并复制。
转到计算机>属性>高级系统设置>环境变量并添加以下系统变量:REACT_NATIVE_PACKAGER_HOSTNAME
作为变量的值,我必须粘贴虚拟机的 ip4。
小智 5
我有同样的问题。我的问题是VirtualBox已安装了几个虚拟以太网适配器,而NPM正在选择其中的一个。禁用“控制面板”>“所有控制面板项目”>“网络连接”中的功能后,Expo应用程序将按预期连接。
| 归档时间: |
|
| 查看次数: |
2872 次 |
| 最近记录: |