React-Native 之 index.android.bundle

本文详细介绍了遇到index.android.bundle错误的解决办法,包括创建assets文件夹、使用正确的打包命令及检查项目配置等步骤,特别强调了确保项目中只有一个正确命名的apk文件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

 问题: index.android.bundle  这个bug 我相信很少同学会遇到,然而就是这个问题,困扰了我跟我的同事多天, 各种方法处理:  进入 android 目录  ./gradlew clean  一下,然后回到项目根目录,react-native run-android  有的时候也可以解决, build 一下也可以,但都没有完美解决这个问题  ;

 

最后解决方案 : 三者都要注意 

1, 项目根目录 执行此命令

第一步:在Android/app/src/main目录下创建一个空的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/

2,检查自己的项目是否使用该插件

react-native-devices-info   // 获取设备类型信息插件

经本人亲测试:创建一个全新的项目,然后安装此插件,启动项目,报错 index.android.bundle 

 3,看看打包apk ,如下图:  最最最重要的完美解决

看一看有没有被改名?或者多久自动打包一次?

里边只允许有一个apk文件,否则同样会报该错 (本人项目就改名了,且几分钟打包一次,所以一直报这个错

 

 

转载于:https://www.cnblogs.com/hai-cheng/p/9146801.html

D:\project\SmallProgram\myApp>yarn dev:rn yarn run v1.22.22 $ npm run build:rn -- --watch > myApp@1.0.0 build:rn > taro build --type rn --watch 👽 Taro v4.1.1 Tips: 预览模式生成的文件较大,设置 NODE_ENV 为 production 可以开启压缩。 Example: $ set NODE_ENV=production && taro build --type rn --watch Installing React-Native related packages: react@^18.2.0 react-dom@^18.2.0 react-native@^0.73.1 @react-native/metro-config@^0.73.2 expo@~50.0.2 @tarojs/taro-rn @tarojs/components-rn @tarojs/rn-runner @tarojs/rn-supporter @tarojs/runtime-rn React-Native related packages have been installed successfully. ATTEHNTION: Package.json has been modified automatically, please submit it by yourself. index.js created WARNING: You should run npx react-native@latest to ensure you're always using the most current version of the CLI. NPX has cached version (0.73.11) != current release (0.79.3) info Welcome to React Native v0.73 info Starting dev server on port 8081... To print qrcode press "q" Welcome to Metro v0.80.12 Fast - Scalable - Integrated info React Native v0.79.3 is now available (your project is running on v0.73.11). info Changelog: https://github.com/facebook/react-native/releases/tag/v0.79.3 info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.79.3 info For more info, check out "https://reactnative.dev/docs/upgrading?os=windows". info Dev server ready i - run on iOS a - run on Android d - open Dev Menu r - reload app info Opening app on Android... info A dev server is already running for this project on port 8081.
最新发布
06-06
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值