我正在使用 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 未更新
发布评论