android ReactNative之Cannot find entry file index.android.js in any of the roots
android ReactNative之Cannot find entry file index.android.js in any of the roots
由于公司要求,想让我去了解一下ReactNative开发,说是为了以后开发的以后方便移植到IOS上。晕!!!没办法,照着React Native的中文开发文档配置环境https://reactnative.cn/docs/0.51/getting-started.html#content,配置过程还算简单,以为很简单,其实还是我太单纯。照着文档创建项目,创建好后运行项目,坑出现了,这个坑我埋了半天的时间,真是太耽误时间了。遇到的其实别的博客上都有说,Cannot find entry file index.android.js in any of the roots,就是这个错误日志,按照其他的博客的解答方式我一一尝试,不幸无一能解决我的问题,反而使用了他们的方案衍生出其他的error日志,是我本来离答案很近又被扯远了,我连续创建了三个项目才将问题解决,在此记录,为人填坑。
在react native以前的版本,index.android.js与index.ios.js是分开的两个文件,在最新版本中这两个文件合并成index.js一个文件了。但是如果你在创建项目之后直接运行,肯定会报Cannot find entry file index.android.js in any of the roots这种类似的错误,因为在根目录下已经不存在index.anroid.js和index.ios.js这两个文件,所以肯定不会检索到,你更改App.js的内容后更不可能生效。
我解决的方式是:创建项目时
react-native init AwesomeProject
cd AwesomeProject
执行完这两个命令后,不要直接去运行,先执行以下命令去创建assets目录:
通过执行
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/
命令会在assets目录下生成两个文件
控制器会提示生成成功
这个时候你再运行react-native run-android,就不会报错了,完美运行。你可以测试一下,通过更改App.js的样式,然后重新reload,样式就会及时生效。
纯是个人经过4、5个小时尝试的方法,真实有效,欢迎来怼。
方法二:
Changed the version of react project to a lower one from here
npm install -g rninit
rninit init [Project Name] --source react-native@0.40.0
Worked okay for both on both iOS and Android on . If you get Error Could not get BatchedBridge. run this
adb reverse tcp:8081 tcp:8081
This worked for me.
android ReactNative之Cannot find entry file index.android.js in any of the roots的更多相关文章
- Cannot find entry file index.android.js in any of the roots:[ Android ]
Changed the version of react project to a lower one from here npm install -g rninit rninit init [Pro ...
- 项目初始化以后出现: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 之 index.android.bundle
问题: index.android.bundle 这个bug 我相信很少同学会遇到,然而就是这个问题,困扰了我跟我的同事多天, 各种方法处理: 进入 android 目录 ./gradlew c ...
- 解决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 scripts from assets 'index.android.bundle' on real device
问题:重新建了一个项目后,运行react-native run-android报: unable to load scripts from assets 'index.android.bundle' ...
- 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 - ...
- 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' 出错?
野路子太多,坑人真的!F**k 言归正传,当你运行 react native 程序的时候出现这个错误 ,如果您使用Windows,请按以下方式运行命令,或者如果出现错误“无法找到条目文件index.a ...
- React-Native开发之原生模块封装(Android)升级版
本文主题:如何实现原生代码的复用,即如何将原生模块封装. (尊重劳动成果,转载请注明出处:http://blog.csdn.net/qq_25827845/article/details/52862 ...
随机推荐
- Makefile--伪目标 (三)
原创博文,转载请标明出处--周学伟http://www.cnblogs.com/zxouxuewei/ 一般情况下,Makefile都会有一个clean目标,用于清除编译过程中产生的二进制文件.我们在 ...
- 第七篇:几个经典的TCP通信函数
前言 在TCP通信中要使用到几个非常经典的函数,本文将对这几个函数进行一个简短的使用说明. socket()函数 函数作用:创建一个网际字节流套接字 包含头文件:sys/socket.h ( 后面几个 ...
- select下拉框不能赋值
前言: 需要用到类似于下面的下拉选择框,按照官方文档写,始终实现不了下拉框赋上值的情况. 过程: 认认真真的看了好几遍文档,但是还没找到原因,不过还是应该感谢自己加入的vue-admin的微信群,大家 ...
- 为什么说在js当中所有类的父类是Object类
代码如下所示: function Parent(add,net,no,teacher) { this.add = add; this.net = net; this.no = no; this.tea ...
- tomcat日志保存在哪里?
tomcat目录下的logs文件夹下.有个catalina.20xx-xx-xx.log
- this、target、currentTarget
this:绑定事件所触发行为的对象 target:最开始冒泡的的对象 currentTarget:事件触发行为的对象 this == target currentTarget和this 是target ...
- 关于layer.photos即照片显示的问题。
在layer组件中,照片显示是不常用,今天做了一些不伤了. 在这里写出来,以备后用. 其中注意几个问题, 1.格式问题. 2.路径问题. 不同的layer有不同的格式,查看layerAPI中发现的格式 ...
- php中关于时间的用法
一.时间戳相关: 当前时间戳:time(); 把时间戳转换为时间显示:date("Y-m-d H:i:s", $a); 把日期时间转换 ...
- mysql 安装流程 兼容8.0.0以上版本 解决修改密码规则问题
背景介绍: 第一次安装mysql服务端,版本8.0.6 遇到了问题:1:不知道流程:2:8.0以上版本密码加密规则修改的解决方案: 1:下载mysql 服务端 https://dev.mysql. ...
- js里面return 和 return false的区别
js里面return 和 return false的区别 1.都可以终止执行当前方法: 2.如果方法A调用了方法B,则在方法A中使用return可以终止程序,但是在方法B中使用return则终止执行B ...