加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

React Native android错误合集

发布时间:2020-12-15 06:25:50 所属栏目:百科 来源:网络整理
导读:新建项目 react-native init TestApp 运行项目 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 serve

新建项目

react-native init TestApp

运行项目

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读