为了账号安全,请及时绑定邮箱和手机立即绑定

unable to load script from assets index.android.bundle

解决如下

unable to load script from assets index.android.bundle

This issue helped me resolve the problem in following steps.

(in project directory) mkdir android/app/src/main/assets

react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res

react-native run-android

现在每次修改代码真机上看效果都需要下面这两步

react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res

react-native run-android

怎么回事啊?谁告诉下怎么解决,多谢


正在回答

2 回答

现在android项目app/src/main里建一个assets文件夹,在使用react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res 命令执行后的效果就是这样,就能运行了。我是用真机调试的

https://img1.sycdn.imooc.com//5ae187fb000123f804960670.jpg 

0 回复 有任何疑惑可以回复我~
#1

杨晓龙0

在MainApplication 有这么和方法, @Override protected String getJSMainModuleName() { return "index"; } 调用js的模块才能调用assets最新的index.android.bundle文件才能看到修改的内容
2018-04-27 回复 有任何疑惑可以回复我~

这个你初始化的代码是不是就一个index.js

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
ReactNative入门与进阶
  • 参与学习       70540    人
  • 解答问题       166    个

React Native跨平台技术入门与进阶

进入课程

unable to load script from assets index.android.bundle

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信