反应本机应用程序工作,但 APK 和 --variant=release 在加载时反复崩溃

react native app works, but both APK and --variant=release crash repeatedly upon loading

运行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/running 变体发布版本不会自动包含捆绑器吗?如何重建并验证捆绑器是否已包含在 apk/variant 版本中?

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

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

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

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

为了确保打包器包含在 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

无耻地取自这个