按照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. Vagrant 命令详解

    1.查看当前登录的用户系统上所有活动的Vagrant环境的状态. vagrant global-status参数:--prune 清除列表中的无效条目   ... ...    

  2. SQL-记录修改篇-008

    修改记录: update table_name  as  a set  a.type = ‘青年' where a.age>18  and  a.age<40 解释:将表中age字段大于1 ...

  3. python------Socket网略编程+动态导入模块

    上节课程回顾: 静态变量:与类无关,不能访问类里的任何属性和方法. 类方法:只能访问类变量. 属性:把一个方法变成静态属性, 反射: __new__:先于__init__执行: __call__: c ...

  4. Go Example--defer

    package main import ( "fmt" "os" ) func main() { f := createFile("/tmp/defe ...

  5. flask,gunicorn,supervisor,nginx配置服务器接口

    1,申请阿里云主机 2,apt-get update 3,apt-get install pip 4,pip install virtualenv 5,virtualenv venv 6,source ...

  6. 十三、springboot (八)Admin

    1.创建server端spring-boot-admin 2.添加依赖 <parent> <groupId>org.springframework.boot</group ...

  7. django模板语言循环字典,及forloop

    views: from django.shortcuts import render,redirect from django.shortcuts import HttpResponse # Crea ...

  8. 将string转为同名类名,方法名。(c#反射)

    using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace stri ...

  9. VSCode TypeScript开发

    下载VSCode VSCode是我使用过最棒的编辑器没有之一. 创建项目 创建目录 首先我们创建一个项目文件夹,比如叫ts_vscode,然后创建一些主要目录,在VSCode中打开项目 目录结构: t ...

  10. 如何修改MSSQL的用户名

    Alter LOGIN sa DISABLE Alter LOGIN sa WITH NAME = [systemAccount] "systemAccount" 为SA的新名称, ...