按照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.)的更多相关文章

  1. React Native踩坑之Unable to load script from assets

    报错: Unable to load script from assets 'index.android.bundle'. Make sure your bundle is packaged corr ...

  2. 解决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 ...

  3. react native中Unable to load script from assets 'index.android.bundle'解决方案

    刚刚朋友问我,说是创建好一个项目,运行后报错:Unable to load script from assets 'index.android.bundle',以前好好的没出现这种现象,于是我找到一个 ...

  4. 项目初始化以后出现: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日 ...

  5. 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 ...

  6. unable to load script from assets 'index.android bundle'

    在Android手机上运行React-native项目时 报错:unable to load script from assets 'index.android bundle'  ,make sure ...

  7. Unable to load script from assets 'index.android.bundle' 出错?

    野路子太多,坑人真的!F**k 言归正传,当你运行 react native 程序的时候出现这个错误 ,如果您使用Windows,请按以下方式运行命令,或者如果出现错误“无法找到条目文件index.a ...

  8. react-native 新手爬坑经历(Could not connect to development server.)

    来,先说下报错出现场景,刚跑完项目加载完是好的,但是双击R后就开始耍小脾气了-红屏出现,如下图 首先检查包服务器是否运行正常.在项目文件夹下输入react-native start或者npm star ...

  9. 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 - ...

随机推荐

  1. flask中如何生成迁移文件

    在flask网站开发中,如果直接对数据库进行修改的话,风险比较高,最好的是由迁移文件生成,这样确保了数据的误操作. 在Flask中可以使用Flask-Migrate扩展,来实现数据迁移.并且集成到Fl ...

  2. Codeforces1062A. A Prank(暴力)

    题目链接:传送门 题目: A. A Prank time limit per test second memory limit per test megabytes input standard in ...

  3. javascript常见的几种事件类型

    第一种事件类型:onchange() <body> <select id="sheng" onchange="fn1();"> < ...

  4. 面向对象的编程思想和Java中类的概念与设计

    面向对象的编程思想学习,面向对象内容的三条主线;1.java类及类的对象2.面向对象的三大特征3.其他关键字学习内容:3.1面向对象与面向过程面向对象与面向过程在应用上的区别 Java中类的概念与设计 ...

  5. SQL 入门了解

    SQL 随着应用程序的功能越来越复杂,数据量越来越大,如何管理这些数据就成了大问题: 读写文件并解析出数据需要大量重复代码: 从成千上万的数据中快速查询出指定数据需要复杂的逻辑. 如果每个应用程序都各 ...

  6. PythonStudy——字典的操作 Dictionary operation

    dic = {'a': 1, 'b': 2} print(dic) # 增: 字典名[key] = 值 => key已存在就是修改值,不存在就是新增值 dic['c'] = 3 print(di ...

  7. PythonStudy1——Python 值拷贝 浅拷贝 深拷贝

    拷贝:对值进行复制的过程 # 值拷贝:应用场景最多  ls = [1, 'abc', [10]] ls1 = ls # ls1直接将ls中存放的地址拿过来  # ls内部的值发生任何变化,ls1都会随 ...

  8. linux kernel driver debug

    1. print printk(): never pr_debug(): always good dev_dbg(): prefered when you have a struct device o ...

  9. win7中安装mysql

    这篇文章主要介绍了如何在win7中安装mysql,所以加上了MySQL的下载过程,希望对需要的人有所帮助大家都知道MySQL是一款中.小型关系型数据库管理系统,很具有实用性,对于我们学习很多技术都有帮 ...

  10. Excel函数之vlookup的用法

    Vlookup函数用法: 实例: 要将编号对照表中的图书名称根据两表中的图书编码字段引入 订单明细中. Vlookup函数 参数一:键入一个需要搜索的字段,这里需要通过订单明细中的图书编号在编号对照离 ...