项目初始化以后出现:Unable to load script from assets 'index.android.bundle
Mac中真机测试React Native project时出现Unable to load script from assets 'index.android.bundle'
刚接触学习React Native,在进行真机调试时,报错出现Unable to load script from assets ‘index.android.bundle’. Make sure your bundle is packaged correctly or you’re running a packager server。这里对此做一下记录;
笔者对此也查了相关的解决方法,但是并没有解决我所遇到的问题,解决方法如下:
第一步:首先切到我们工程的根目录下,然后在android/app/src/main目录下新建一个assets文件夹,可以在终端中执行以下命令建立:
mkdir android/app/src/main/assets
- 1
当然也可以在Android Studio中手动建立;
第二步:同样需要在我们工程的根目录下,执行以下命令:
react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
- 1
第三步:重新运行以下命令即可:
react-native run-android
- 1
然而,这样并没有解决上述问题,依然报错,且此时会出现另外一个问题:
Cannot find entry file index.android.js in any of the roots: ["/Users/******/ReactNativeProjects/FirstReactApp"]
- 1
这时我们去assets文件夹下才发现,第二步的命令并没有在assets文件夹中生成我们所需的文件,里面没有任何文件生成,此时笔者继续查找,在Stack Overflow中找到了解决方法,用下面的命令替换刚才第二步的命令:
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
- 1
原来是index.android.js已经改成index.js,难怪找不到呢!!!
使用上述命令后,此时在assets文件夹下会多出index.android.bundle和index.android.bundle.meta两个文件;
再重新运行工程,终于出现运行成功的界面啦!
小结:遇到问题时要敢于去解决,多查找问题的原因,这里index.android.bundle是用来调用系统原生控件的js脚本,每次当你改变了 index.js时,需要使用上面的命令及时地更新index.android.bundle,然后打包才可以把新的index.js应用上,所以当没有index.android.bundle文件时,React Native是无法运行的;
项目初始化以后出现:Unable to load script from assets 'index.android.bundle的更多相关文章
- 解决React Native unable to load script from assets index.android.bundle on windows
React Native运行的时候,经常碰到React Native unable to load script from assets index.android.bundle on windows ...
- react native中Unable to load script from assets 'index.android.bundle'解决方案
刚刚朋友问我,说是创建好一个项目,运行后报错:Unable to load script from assets 'index.android.bundle',以前好好的没出现这种现象,于是我找到一个 ...
- unable to load script from assets 'index.android bundle'
在Android手机上运行React-native项目时 报错:unable to load script from assets 'index.android bundle' ,make sure ...
- Unable to load script from assets 'index.android.bundle'.Make sure your bundle is packaged correctly or you're running a packager server
curl -k 'http://localhost:8081/index.android.bundle?platform=android' > android/app/src/main/asse ...
- Unable to load script from assets 'index.android.bundle'.make sure you bundle is packaged correctly
解决此问题 以下方法每次都需要执行命令2才能更新 1.创建assets目录 mkdir android/app/src/main/assets 2.执行命令 react-native bundle - ...
- Unable to load script from assets 'index.android.bundle' 出错?
野路子太多,坑人真的!F**k 言归正传,当你运行 react native 程序的时候出现这个错误 ,如果您使用Windows,请按以下方式运行命令,或者如果出现错误“无法找到条目文件index.a ...
- React Native: unable to load scripts from assets 'index.android.bundle' on real device
问题:重新建了一个项目后,运行react-native run-android报: unable to load scripts from assets 'index.android.bundle' ...
- react-native 新手爬坑经历(unable to load script from assets 和could not connect to development server.)
按照https://reactnative.cn/docs/0.51/getting-started.html教程新建的项目 react-native init AwesomeProject cd A ...
- React Native踩坑之Unable to load script from assets
报错: Unable to load script from assets 'index.android.bundle'. Make sure your bundle is packaged corr ...
随机推荐
- IO高级应用关于字符码表
ASCII码表: 计算机里只有数字,我在计算机软件里的一切都是用数字来表示,屏幕上显示的一个个字符也不例外.计算机诞生在美国,最开始所用到字符就是我们现在键盘上的一些符号和少数几个特殊的符号,每一个字 ...
- python爬虫知乎问答
python爬虫知乎问答 import cookielibimport base64import reimport hashlibimport jsonimport rsaimport binasci ...
- FOB cost---从工厂到码头的费用
1.主要是港杂费:陆运400元起,2个方450元,三个方500元,3个方以上按100元/方算起.
- ucore-lab1-练习5report
实验5--实现函数调用堆栈跟踪函数 需要完成kdebug.c中函数print_stackframe的实现,可以通过函数print_stackframe来跟踪函数调用堆栈中记录的返回地址. 一.函数堆栈 ...
- CentOS7双网卡绑定配置
step1:创建绑定文件 [root@node-1 ~]# vi /etc/sysconfig/network-scripts/ifcfg-bond0 TYPE="bond"BOO ...
- HDU 5828 Rikka with Sequence(线段树区间加开根求和)
Problem DescriptionAs we know, Rikka is poor at math. Yuta is worrying about this situation, so he g ...
- 199. Binary Tree Right Side View 从右侧看的节点数
[抄题]: Given a binary tree, imagine yourself standing on the right side of it, return the values of t ...
- 微擎开发------day03
微擎系统的路由 首先附上一张完整的项目目录图,可下载图片后查看详情 详细的路由介绍 (1)后台系统路由 例如:http://local.drp.com/web/index.php?c=home& ...
- Python开发——【条件】语句
单分支 # if 条件: # 满足条件后要执行的代码 if 2>1: print("2>1") 双分支 # if 条件: # 满足条件后要执行的代码 # else: # ...
- 通过类名或者jar名查询所在jar包
一.问题 例如我想查看一下FilterSecurityInterceptor的源码,但是我不知道它在maven依赖中的哪个jar包中 二.解决方案 http://www.findmaven.net/ ...