Search code examples
androidandroid-studioreact-nativeapkbundler

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


After running logcat. I discovered the follow error exception:

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.

Doesn't creating an apk/running the variant release version automatically include the bundler? How do I rebuild and verify that the bundler has been included in the apk/variant release?

I tried adding bundleAssetName: "index.android.bundle", to

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

I still got the same issue(repeatedly crashing). I did a search for "exception" and found this error:

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

Solution

  • In order to make sure the bundler is included in the apk, this was needed

    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
    

    Shamelessly taken from this post.