React Native: Unable to download JS bundle from the Dev Server

时间:2016-02-12 21:59:19

标签: android reactjs react-native genymotion

I am trying to run basic AwesomeProject app that react native have by default, on Windows 7 machine through Genymotion. The Virtual Devices that i have tried is Nexus 7 4.2.2 and Nexus 6 5.1.0.

I am using Nodejs (4.3.0)

I followed below steps to overcome JS bundle issue, but still no success:

  • started Virtual device in Genymotion
  • react-native run-android //deployed the app on virtual device
    • then red screen appears with an error message
  • react-native start //started the server
  • Updated Debug server host for device with my machine IP-address:8081

    • Visited back to app screen and clicked Reload JS, but no success
  • I have also tried re-installing the watchman, as many people on related post suggested to do so, but still no success.

Moreover, I have seen another solution on React.js official docs, i.e executing this command "adb reverse tcp:8081 tcp:8081" and then starting the server and updating the IP-address and port respectively. But this solution is useful if i test the app on my personal device rather than emulator.

Any suggestion or alternate solution is really appreciated.

Thanks.

3 个答案:

答案 0 :(得分:1)

行!!

首先,你需要做出反应 - 本地开始。

当应用程序部署在设备上时,您可以点击“菜单”按钮或摇动“单元格”以加载菜单,大多数现代手机都没有菜单按钮。 当它加载 查找开发设置。  在下面的调试中,单击设备的调试服务器主机和端口 将DHCP分配给您的系统本地网络IP。 您可以在ubuntu上执行ifconfig查看您的IP。

将您的IP地址设置为192.168.x.x:8081 重新加载JS。

你将全力以赴。 :)

重要提示:确保您的电话和系统位于同一WIFI上。

答案 1 :(得分:0)

启动打包者:

react-native start

在浏览器中转到此网址

http://localhost:8081/index.android.bundle?platform=android

一旦加载,它应该提供比你拥有的更好的错误响应。

答案 2 :(得分:0)

当我在连接到工作 VPN 的情况下运行 React Native 打包程序时遇到了这个问题,一旦我断开工作 VPN 连接,打包程序就能够为我的应用程序选择正确的 IP 接口。