项目初始化以后出现: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 ...
随机推荐
- js 一些兼容检测
1. IE5.0之前不支持 document.getElementById(),但存在 document.all[] function getElementById(id) { if(document ...
- java引用
java1.2之后将引用分为强引用(Strong Reference).软引用(Soft Reference).弱引用(Weak Reference).虚引用(Phantom Reference)4种 ...
- 考研结束,重返python
因为考研的原因,python的学习告一段落,现在考验终于结束了,也抓眼又到了新的一年.新的一年里也要继续加油啊.python学习之路还要继续下去,但是毕竟有将近半年没有鹏编程了,首先我还是需要好好的复 ...
- python的基本用法(四)文件操作使用
#读文件,文件必须存在才能读f=open('操作文件',encoding='utf-8')res =f.read()print(res)f.close()#写文件fw=open('操作文件',mode ...
- Java 后台验证的工具类
Java 后台验证的工具类 public class ValidationUtil { //手机号 public static String mobile = "^( ...
- 主机性能监控之wmi 获取系统信息及内存性能信息
标 题: 主机性能监控之wmi 获取系统信息及内存性能信息作 者: itdef链 接: http://www.cnblogs.com/itdef/p/3990240.html 欢迎转帖 请保持文本完整 ...
- mybatis 插入数据 在没有commit时 获取主键id
<insert id="insert" parameterType="Mail" useGeneratedKeys="true" ...
- ABP框架系列之九:(Abp-Session-会话)
Introduction ASP.NET Boilerplate provides IAbpSession interface to obtain current user and tenant wi ...
- abaqus6.14导出网格inp以及导入inp以建模
建好part,组装后,划分网格,然后建立job,之后write input就可以在工作目录生成刚才新建网格的单元和节点编号信息了. *Heading ** Job name: buildmodel M ...
- python基本数据类型之列表和元组
python基本数据类型之列表与元组 python中list与tuple都是可以遍历类型.不同的是,list是可以修改的,而元组属于不可变类型,不能修改. 列表和元组中的元素可以是任意类型,并且同一个 ...