创建发布版本时 index.android.bundle 未更新 [英] index.android.bundle not updating when creating release build

查看:55
本文介绍了创建发布版本时 index.android.bundle 未更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 ReactNative & 开发一个项目它在调试版本中运行良好(通过 react-native run-android 安装时,但是当我生成一个发布版本时,它会在我打开它时立即崩溃,根据日志,它无法加载脚本,并且 android/app/src/main/assets 目录为空.

I'm working on a Project in ReactNative & it's working fine in debug build (When installing via react-native run-android but When I generate a release build it crashes as soon as I open it, according to logs it's unable to load script, and android/app/src/main/assets directory is empty.

要解决这个,我必须运行以下命令: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

To resolve this I had to run these commands: 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

rm -rf ./android/app/src/main/res/drawable-*

但是现在文件 index.android.js 不会在发布版本中更新,所以我每次需要发布版本时都必须运行上述命令,我做错了什么?

But now the file index.android.js won't update in a release build, so I have to run the above commands every time I need a release build, what am I doing wrong?

这是我的packages.json 详细信息:

Here are my packages.json details:

"scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },



"react": "16.8.3",
    "react-native": "0.59.5"

简而言之:如何在生成发布版本时自动创建或更新 index.android.bundle?

In short: How to create or update index.android.bundle automatically when I generate a release build?

推荐答案

第一次按照流程操作.

mkdir 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 


npm start -- --reset-cache

react-native run-android

如果你想要一个apk文件

if you want to take an apk file

cd android && ./gradlew clean

终于

./gradlew assembleRelease

基本上以下命令对我有用

Basically The below commands worked for me

cd android
./gradlew clean
./gradlew assembleRelease

这篇关于创建发布版本时 index.android.bundle 未更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆