加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

react native android failed to load JS bundle

发布时间:2020-12-15 04:38:16 所属栏目:百科 来源:网络整理
导读:http://stackoverflow.com/questions/32572399/react-native-android-failed-to-load-js-bundle adb reverse tcp:8081 tcp:8081 【打开command+m】输入ip配置 :127.0.0.1:8081 需注意要有端口号不然会有bug另外 I'm trying to run AwesomeProject on my Ne

http://stackoverflow.com/questions/32572399/react-native-android-failed-to-load-js-bundle


adb reverse tcp:8081 tcp:8081


【打开command+m】输入ip配置 :127.0.0.1:8081 需注意要有端口号不然会有bug另外


I'm trying to run AwesomeProject on my Nexus5 (android 5.1.1).

I'm able to build the project and install it on the device. But when I run it,I got a red screen saying

Unable to download JS bundle. Did you forget to start the development server or connect your device?

In react native iOS,I can choose to load jsbundle offline. How can I do the same thing for Android? (Or at least,where can I configure the server address?)

Update

To run with local server,run the following commands under your react-native project root directory

  1. react-native start > /dev/null 2>&1 &
  2. adb reverse tcp:8081 tcp:8081

please take a look at dsissitka's answer for more details.

To run without a server,bundle the jsfile into the apk by running:

  1. create an assets folder underandroid/app/src/main
  2. curl "http://localhost:8081/index.android.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读