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 - ...
随机推荐
- ImageLorderUtil
import android.content.Context;import android.graphics.Bitmap;import android.os.Environment; import ...
- 用变量替换指定的字符串,sed: -e 表达式 #1, 字符 29: “s”的未知选项
在shell脚本里,使用sed,然后用变量替换指定的字符串,一直出现这个错误:但是单独运行在外面可以 把分隔符/替换成#就可以: sed "s#revision=.*#revision=$s ...
- 用jquery得到select选中的值
<select class="pushtype" name="push_type" onchange="pushType(this)" ...
- 1.1.17 Word在表格中插入竖排文字,显示一半
隐藏效果如下所示: 这是因为文字的[段落行距]设置为[固定值],将文字选中,设置为[单倍行距]即可.
- linux tomcat jvm调优
修改TOMCAT_HOME/bin/catalina.sh文件: # OS specific support. $var _must_ be set to either true or false. ...
- Batch Close process
@echo offecho.rem Kill all chrome drivertaskkill /im chromedriver.exe /f pause
- Win10下JDK环境变量的设置
1.找到jdk正确的安装路径 2.打开环境变量设置 打开"资管管理器"后,右击"此电脑",点击"属性" 然后点击"高级系统设置&q ...
- [UE4]Widget Switcher:控件切换器
一.Widget Switcher可以有很多子控件,但一次只会显示一个子控件.所有的子控件默认情况下都是充满整个Widget Switcher容器 二.Widget Switcher.Active W ...
- LeetCode【88. 合并两个有序数组】
首先想到的方法就是,假设一个nums3数组,然后,比较nums1与nums2的数值大小,然后,放在nums3中,再将nums3转移到nums1中. 实现起来很麻烦,1.没有考虑到下标问题,结果就Arr ...
- python函数嵌套定义
python的这个特性是很特别的,与C#和C++都不一样.请看下面的例子 def outFun(): def innerFun_0():#1.在内部定义一个函数 print("i am fi ...