折腾:
【已解决】Mac中搭建ReactNative的Android开发环境
期间,在Android手机中用Expo去扫描React Native的app的QR code,结果出错:
Something went wrong
Could not load exp://192.168.0.118:19000
Network response timed out.
去确保笔记本的WI-FI和android手机用的都是同一个WI-FI,结果再去扫描,还是出错。
刚注意到,可以点击 View error log,去看看:
Uncaught Error: java.net.SocketTimeoutException
Time: Fatal Error
现在再去:
terminal中,重新运行,根据提示,去输入:R,重新运行
再去扫描,看看能否打开,问题依旧。
想起来了:
之前也遇到类似问题:
Mac中,调试本地Chrome中打开的localhost的ReactJS,也是全局代理的翻墙的话,则localhost无法打开
-》此处Android手机中,为了能用上Google Play和下载安装app,而影梭设置了ss的全局代理了,所以去:
设置为自动代理:
然后android中再去试试Expo的扫码
然后就可以正常加载了:
加载到100%后,即可看到页面:
Open up App.js to start working on your app!
Changes you make will automatically reload.
Shake your phone to open developer menu.
然后Mac中terminal中也可以看到连接上了:
21:32:59: Error: You are using npm version 5.0.0. We recommend version 4.6.1. To install it, run ‘npm i -g [email protected]’. 21:33:00: Warning: Problem validating fields in app.json. See https://docs.expo.io/versions/v21.0.0/guides/configuration.html. 21:33:00: • ‘slug’ should match pattern "^[a-zA-Z0-9\-]+$". 21:33:00: Your JavaScript transform cache is empty, rebuilding (this may take a minute). 21:33:12: Problem checking node_modules dependencies: Unexpected end of JSON input 21:33:36: Finished building JavaScript bundle in 36547ms 21:33:38: Running app on SM919 in development mode |
【总结】
之前android中为了能翻墙下载Expo,而把影梭的翻墙设置为全局代理,导致Expo此处无法打开局域网的地址,所以报错。
解决办法是:
把翻墙的影梭的代理设置为:
绕过局域网
或
绕过局域网和大陆地址
即可,Expo即可正常访问本地局域网的192.168.0.xxx的地址,即可正常加载页面。
转载请注明:在路上 » 【已解决】Android中Expo扫码React Native的app出错:Something went wrong Could not load exp 19000 Network response timed out