配置react-native环境时候报错:

unable to load script from assets 'index.android.bundle'.Make sure your bundle ispackged correctly or you are running a packger server.

如图:

这里写图片描述


百度了很久,好像没有多少真正对症的方法。

去stackoverflow看了很多帖子,也是一个个试,最后发现一个不是最佳的回复挺有道理,试了一下果然OK。
这里写图片描述

说是新版本文件名已经从index.android.js变为了index.js;

至于assets文件夹就是用来存放index.android.bundle等文件用;

按照步骤:

1 新建assets

进入\android\app\src\main
新建assets文件夹

2 修改entry–file

根目录cmd运行命令:

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

3 运行run-android

重新运行run-android

此时,结果为:
这里写图片描述


借鉴

GitHub 加速计划 / ass / assets
28
1
下载
Ultralytics assets
最近提交(Master分支:2 个月前 )
aed12dc3 Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com> Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> 1 个月前
f79c74f0 1 个月前
Logo

新一代开源开发者平台 GitCode,通过集成代码托管服务、代码仓库以及可信赖的开源组件库,让开发者可以在云端进行代码托管和开发。旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐