Android释放构建使用纱线工作区中的React-native(0.68.2)monorepo中的崩溃(0.68.2)

发布于 2025-02-04 02:12:01 字数 1544 浏览 4 评论 0 原文

我使用的是使用纱线工作区创建的MonorePo,其中包含一个具有反应的(0.68.2)项目(移动文件夹)的TypeScript和一个公共文件夹,其中包含在项目中要共享的通用文件。在这里,移动项目取决于公共文件,我将其配置为参考此

从Android开始,该应用在调试模式下运行良好。当我创建发行版构建时,APK将成功生成。安装应用程序后,打开时,它会在打开后立即崩溃。在观察错误时,捆绑包似乎存在问题。我尝试手动运行 bundle 命令包装它并尝试生成APK,但仍会导致相同的错误。

logcat的错误:

2022-06-03 22:36:28.457 5699-5723/? E/AndroidRuntime: FATAL EXCEPTION: create_react_context
Process: com.myapp.mobile, PID: 5699
java.lang.RuntimeException: Unable to load script. Make sure you're either running Metro (run 'npx react-native start') or that your bundle 'index.android.bundle' is packaged correctly for release.
    at com.facebook.react.bridge.CatalystInstanceImpl.jniLoadScriptFromAssets(Native Method)
    at com.facebook.react.bridge.CatalystInstanceImpl.loadScriptFromAssets(CatalystInstanceImpl.java:248)
    at com.facebook.react.bridge.JSBundleLoader$1.loadScript(JSBundleLoader.java:29)
    at com.facebook.react.bridge.CatalystInstanceImpl.runJSBundle(CatalystInstanceImpl.java:277)
    at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1422)
    at com.facebook.react.ReactInstanceManager.access$1200(ReactInstanceManager.java:138)
    at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:1111)
    at java.lang.Thread.run(Thread.java:923)

有什么建议吗?

I am using monorepo created using Yarn Workspaces with Typescript which has a react-native (0.68.2) project (mobile folder) and a common folder which contains the common files to be shared across projects. Here the mobile project is dependent on common files and I have configured it referring to this doc.

Starting with Android, the app runs fine in debug mode. When I create a release build, the apk is generated successfully. After installing the app, on opening, it crashes as soon as it opens. On observing the error, it looks like there is a problem with the bundle. I tried manually running the bundle command for packing it and tried generating the apk, but it still results in the same error.

Error from LogCat:

2022-06-03 22:36:28.457 5699-5723/? E/AndroidRuntime: FATAL EXCEPTION: create_react_context
Process: com.myapp.mobile, PID: 5699
java.lang.RuntimeException: Unable to load script. Make sure you're either running Metro (run 'npx react-native start') or that your bundle 'index.android.bundle' is packaged correctly for release.
    at com.facebook.react.bridge.CatalystInstanceImpl.jniLoadScriptFromAssets(Native Method)
    at com.facebook.react.bridge.CatalystInstanceImpl.loadScriptFromAssets(CatalystInstanceImpl.java:248)
    at com.facebook.react.bridge.JSBundleLoader$1.loadScript(JSBundleLoader.java:29)
    at com.facebook.react.bridge.CatalystInstanceImpl.runJSBundle(CatalystInstanceImpl.java:277)
    at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1422)
    at com.facebook.react.ReactInstanceManager.access$1200(ReactInstanceManager.java:138)
    at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:1111)
    at java.lang.Thread.run(Thread.java:923)

Any Suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

抹茶夏天i‖ 2025-02-11 02:12:01

捆绑包被包装并放置在错误的路径中,这导致了此错误。
始终应包装捆绑包并仅在此路径 Android \ App \ Src \ Main \ Assets \ Index.android.bundle.Bundle for Android中。以下命令将正确执行。

npx  react-native bundle --platform android --dev false --entry-file index.js --bundle-output android\app\src\main\assets\index.android.bundle

The bundle was packed and placed in the wrong path which was causing this error.
Always the bundle should be packed and placed in only in this path android\app\src\main\assets\index.android.bundle for android. The below command will do it correctly.

npx  react-native bundle --platform android --dev false --entry-file index.js --bundle-output android\app\src\main\assets\index.android.bundle
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文