首页 > 解决方案 > 反应本机应用程序有效,但 APK 和 --variant=release 在加载时反复崩溃

问题描述

运行 logcat 后。我发现了以下错误异常:

AndroidRuntime: java.lang.RuntimeException: Unable to load script from assets 'index.android.bundle'. Make sure your bundle is packaged correctly or you're running a packager server.

创建 apk/运行变体发布版本不会自动包含捆绑器吗?如何重建并验证捆绑程序是否已包含在 apk/variant 版本中?

我尝试添加bundleAssetName: "index.android.bundle",

project.ext.react = [
    entryFile: "index.js",
    bundleAssetName: "index.android.bundle",
]

我仍然遇到同样的问题(反复崩溃)。我搜索了“异常”并发现了这个错误:

java.lang.IllegalArgumentException: Requested window android.os.BinderProxy@b60a260 does not exist

标签: androidandroid-studioreact-nativeapkbundler

解决方案


为了确保打包程序包含在 apk 中,这是必需的

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

无耻地取自这篇文章。


推荐阅读