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 AwesomeProject
react-native run-android
然后就立马错误了, 错误1:unable to load script from assets ‘index.android bundle’ ,make sure your bundle is packaged correctly or youu’re runing a packager server
解决办法
1,在 android/app/src/main 目录下创建一个 assets空文件夹
mkdir android/app/src/main/assets
2,在项目根目录运行
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/
注意了,是编译index.js而不是index.android.js,因为react-native新版本已经没有index.android.js和index.ios.js两个文件了,只有一个index.js文件,所以要编译index.js
会发现 assets文件夹下多出两个文件
index.android.bundle index.android.bundle.meta
3,重新react-native run-android
*错误2:could not connect to development server.
Try the follwing to fix the issue:*

解决办法:
重新编译index.js文件(走一遍错误一中的第2部),在重新运行react-native run-android
双击R键刷新android模拟器或者点击下
然后
另外运行ios时,如果想指定某个模拟器
react-native run-ios –simulator “iPhone X”
查看iOS设备:在终端中输入
xcrun simctl list devices
react-native 新手爬坑经历(unable to load script from assets 和could not connect to development server.)的更多相关文章
- React Native踩坑之Unable to load script from assets
报错: Unable to load script from assets 'index.android.bundle'. Make sure your bundle is packaged corr ...
- 解决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
Mac中真机测试React Native project时出现Unable to load script from assets 'index.android.bundle' 2018年01月21日 ...
- react-native启动时红屏报错:Unable to load script.Make sure you're either running a metro server or that ....
一.报错信息内容 我是在Android Studio中运行启动react-native项目时报的这个错误 1.报错提示:Unable to load script.Make sure you're e ...
- 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' 出错?
野路子太多,坑人真的!F**k 言归正传,当你运行 react native 程序的时候出现这个错误 ,如果您使用Windows,请按以下方式运行命令,或者如果出现错误“无法找到条目文件index.a ...
- react-native 新手爬坑经历(Could not connect to development server.)
来,先说下报错出现场景,刚跑完项目加载完是好的,但是双击R后就开始耍小脾气了-红屏出现,如下图 首先检查包服务器是否运行正常.在项目文件夹下输入react-native start或者npm star ...
- 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 - ...
随机推荐
- jar包不能乱放【浪费了下午很多时间】
不能放在类路径下(也即是src文件夹下),然后再buildpath 必须放在web-inf文件夹下 这样才能tomcat找打jar文件
- ARTIFICIAL INTELLIGENCE FOR GAMES (Ian Millington / John Funge 著)
相关网站:http://www.ai4g.com PART I AI AND GAMESCHAPTER1 INTRODUCTIONCHAPTER2 GAME AIPART II TECHNIQUESC ...
- 学习Unity -- 理解依赖注入(IOC)三种方式依赖注入
IOC:英文全称:Inversion of Control,中文名称:控制反转,它还有个名字叫依赖注入(Dependency Injection).作用:将各层的对象以松耦合的方式组织在一起,解耦,各 ...
- Python Json & Pickle模块
用于序列化的两个模块 Json,用于字符串 和 python数据类型间进行转换 Pickle,用于python特有的类型 和 python的数据类型间进行转换 Json模块提供了四个功能:dumps. ...
- Git 2.x 中git push时遇到 push.default 警告的解决方法
近在学习使用 git&GitHub,然后今天遇到了一个问题.在执行 git add 和 git commit 操作之后,再进行 git push 操作,出现了如下提示: $ git push ...
- Docker入门与实战讲解
转载自:http://blog.csdn.net/relax_hb/article/details/69668815 简述 Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包 ...
- Excel技巧--巧用差异化插入空行
假设有上面这一列,要求在不同城市之间插入一空行相隔开.数据少的时候可以手动操作,但数据量大时,就需要以下技巧: 1.复制该列(除去标题),并粘贴到右侧一列,但上方要隔开一个单元格B2: 2.将这两列选 ...
- LiveBindings --- 把对象之间的属性绑定起来
有了 FireMonkey 框架,它不同于 VCL ,以往的数据感知控件不能放在它上面,所以 XE2 提供了 LiveBindings 功能作为替代方案.另外它也是个通用的基础设施,同样可用于传统的V ...
- linux用ssh登录卡或者慢
原因:有可能是客户端在登录服务器时,服务器会先根据客户端的IP根据DNS去查找主机名,如果客户端的DNS服务器出现问题或者主机名有问题,就会卡一段时间 解决办法: # vi /etc/ssh/sshd ...
- 【python】脚本连续发送QQ邮件
今天习得用python写一个连续发送QQ邮件的脚本,经过测试,成功给国内外的服务器发送邮件,包括QQ邮箱.163邮箱.google邮箱,香港科技大学的邮箱和爱丁堡大学的邮箱.一下逐步解答相关技巧. 首 ...