JS bundle isn't included in Android production build with Gradle 3.4
See original GitHub issueReact Native version: 0.59.8
Steps To Reproduce
- Open Android-Studio and update
com.android.tools.build:gradle
to3.4.1
in the main Gradle file - Sync Gradle
- Try to build an APK and install it on an Android Simulator (
adb install
) - See the app crash
- Run
adb logcat
to get the logs of the Android Simulator - See the exception saying
Unable to load script from assets 'index.android.bundle'
I encountered the issue and it was fixed by downgrading to 3.3
(see this reply).
Reason of the issue
The explanation in this comment:
Apparently, Gradle 3.2.0 changed the location to which it generates asset bundles. RN expects its JS asset bundle to be in a specific path, which is the path used by Gradle 3.1.4. Because G3.2.0 puts them in a different spot, RN cannot find the JS asset bundle, and thus the files with the Javascript to run. Ergo, the crash in release mode.
Possible fix
I think it would be a good idea to change the default JS bundle path in react.gradle
.
WDYT? If this is a good fix, I’d be happy to try and implement it.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:10 (9 by maintainers)
Top Results From Across the Web
react-native android bundle is not loading the assets for release
I've tried updating gradle and updating react-native, but neither seems to help. I'm not sure what to try at this point. com.android.tools.build ......
Read more >Android Gradle plugin release notes - Android Developers
If the specified plugin version has not been downloaded, Gradle downloads it the next time you build your project or click File >...
Read more >Installation - Gradle
Install the Gradle build tool on Linux, macOS or Windows, either manually or using a package manager like SDKMAN! or Homebrew.
Read more >Bundling React Native during Android release builds
Looking into the react-native directory reveals a Gradle file that defines a bundling task. This is the react.gradle file that is mentioned in...
Read more >Android Platform Guide - Apache Cordova
Android Platform Guide. This guide shows how to set up your SDK environment to deploy Cordova apps for Android devices, and how to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
My workaround for this was to move the
index.android.bundle
fromapp/build/generated
toapp/src/main/assets
, and then run gradle again to bundle this in.Do this at your own risk, it definitely took some pain to figure this out, and may have unforeseen consequences
I run this to generate a release:
It was fixed in 0.59 so you have to upgrade React Native or search for workaround which i can’t remember where i found it.