React Native Android app does not load JS bundle properly

Viewed 416

I have a problem with the bundling of JS in my RN 0.63.3 app when building for Android.

I have the variants release, debug, dev and alphaRelease. debug works as expected and connects to the bundle server, but the other ones cause a crash/white screen when running the app.

But if I run a ./gradlew assembleAlphaRelease and install the app, it crashes, telling me that the file app/src/main/assets/index.android.bundle cannot be found. (It's the same with release and dev). I can see that it runs the bundleJsAndAssets step though.

When I search for the index.android.bundle after building, I can see these files which all have the same content, but none of them are found by the running app.

./app/build/generated/assets/react/alphaRelease/index.android.bundle
./app/build/intermediates/merged_assets/alphaRelease/out/index.android.bundle
./app/build/intermediates/merged_assets/alphaRelease/mergeAlphaReleaseAssets/out/index.android.bundle
./app/build/intermediates/assets/alphaRelease/index.android.bundle

If I run command below, there will be an index.android.bundle at the right location, and the app will work as expected after rebuilding.

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

I guess that my app should load the JS from the file in ./app/build/generated/assets/react/alphaRelease/index.android.bundle?

It can already load the assets without problems, from ./app/build/generated/res/react/alphaRelease/drawable*, but not the JS bundle.

I've tried various settings in the project.ext.react section of build.gradle but nothing seems to help. It acts the same if I set jsBundleDirAlphaRelease: "$buildDir/intermediates/assets/alphaRelease", etc.

So: How can I make the app load the JS bundle from one of the locations where it exists, so I don't have to manually generate this file every time?

0 Answers
Related