question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to load script from assets 'index.android.bundle'. Make sure your bundle is packaged correctly or you're running a packager server. App crash in release build only

See original GitHub issue

Environment

Done in 2.05s. - /usr/local/bin/yarn
      npm: 6.4.1 - /usr/local/bin/npm
      Watchman: 4.7.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.0, macOS 10.14, tvOS 12.0, watchOS 5.0
      Android SDK:
        Build Tools: 23.0.1, 23.0.2, 23.0.3, 24.0.2, 25.0.0, 25.0.2, 25.0.3, 26.0.1, 26.0.2, 27.0.3, 28.0.0, 28.0.2, 28.0.3
        API Levels: 22, 23, 24, 25, 26, 27, 28
    IDEs:
      Android Studio: 3.2 AI-181.5540.7.32.5056338
      Xcode: 10.0/10A255 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.5.0 => 16.5.0
      react-native: 0.57.1 => 0.57.1
    npmGlobalPackages:
      create-react-native-app: 2.0.2
      react-native-cli: 2.0.1

Description

I get the error below on release builds. I don’t see the issue in my dev environment i.e. react-native run-android. I installed the apk on my Pixle 2 XL - Android Pi and the app immediately crashes. I got the error below from my Firebase console (Crashlytics)

Fatal Exception: 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.
       at com.facebook.react.bridge.CatalystInstanceImpl.jniLoadScriptFromAssets(CatalystInstanceImpl.java)
       at com.facebook.react.bridge.CatalystInstanceImpl.loadScriptFromAssets(CatalystInstanceImpl.java:216)
       at com.facebook.react.bridge.JSBundleLoader$1.loadScript(JSBundleLoader.java:32)
       at com.facebook.react.bridge.CatalystInstanceImpl.runJSBundle(CatalystInstanceImpl.java:243)
       at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1114)
       at com.facebook.react.ReactInstanceManager.access$900(ReactInstanceManager.java:116)
       at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:913)
       at java.lang.Thread.run(Thread.java:764)

Reproducible Demo

Let us know how to reproduce the issue. Include a code sample, share a project, or share an app that reproduces the issue using https://snack.expo.io/. Please follow the guidelines for providing a MCVE: https://stackoverflow.com/help/mcve

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:7
  • Comments:23 (4 by maintainers)

github_iconTop GitHub Comments

55reactions
vinnyhowardcommented, Apr 25, 2019

For me this combination worked using "react-native": "0.59.4"

  • In gradle-wrapper.properties add distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
  • in root build.gradle use classpath 'com.android.tools.build:gradle:3.3.0'
  • in app build.gradle I have:
project.ext.react = [
        entryFile: "index.js",
        bundleAssetName: "index.android.bundle",
        bundleInAlpha: true,
        bundleInBeta: true
]

right above apply from: "../../node_modules/react-native/react.gradle"

46reactions
sryzecommented, Nov 10, 2018

For some reason I had import com.facebook.react.BuildConfig; in my MainAplication file (I guess due to some smart ass auto import fixing feature of IntelliJ), and therefore BuildConfig.DEBUG was set to false. Because of this:

    public boolean getUseDeveloperSupport() {
      return BuildConfig.DEBUG;
    }

React Native was always trying to load index.android.bundle from the app pacakge, not from the dev server. Removing the import com.facebook.react.BuildConfig line fixed the issue for me 🎆 🍺 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to load script from assets 'index.android.bundle'. Make ...
Unable to load script from assets 'index.android.bundle'. Make sure your bundle is packaged correctly or you're running a packager server.
Read more >
React Native: Unable to load script: index. android.bundle
Step 1: I am using React Native version 0.63.2 like below, and I want to build an android app by using Fastlane for...
Read more >
Fixing React-Native android release build - wesionaryTEAM
Make sure you're either running Metro (run 'npx react-native start') or that your bundle 'index.android.bundle' is packaged correctly for release.
Read more >
Build and test your Android App Bundle
Deploy using app bundles with Android Studio · Select Run > Edit Configurations from the menu bar. · Select a run/debug configuration from...
Read more >
What does the error message 'Unable to load script ... - Quora
Make sure you are either running a Metro server or that your bundle 'index.Android.bundle' is packaged correctly for release" mean in React Native...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found