react-native: Unable to load script from assets 'index.android.bundle'.make sure you bundle is packaged correctly.....

Environment: OS: macOS Sierra 10.12.6 Node: 8.3.0 Yarn: 0.27.5 npm: 5.5.1 Watchman: 4.9.0 Xcode: Xcode 9.2 Build version 9C40b Android Studio: 3.0 AI-171.4443003

Packages: (wanted => installed) react: ^16.3.0-alpha.0 => 16.3.1 react-native: 0.55.0 => 0.55.0

Steps to Reproduce

1:react-native init Test 2:cd Test 3:react-native run-andorid use android virtual genymotion google nexus 6p-7.1.0

Expected Behavior

run normal like ios is ok.

Actual Behavior

if release is ok . can’t load script and can’t debug start chrome.

Unable to load script from assets 'index.android.bundle'.make sure you bundle is packaged correctly.....

node

bundle

installsuccess

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 49 (3 by maintainers)

Most upvoted comments

I have resolved doing this commands:

// create new project
react-native init awesomeproject

// use react native 0.55.4
npm remove --save react-native
npm i --save react-native@0.55.4

npm remove babel-preset-react-native
npm i --save babel-preset-react-native@2.1.0

// create folder assets in android\app\src\mainoid
mkdir android\app\src\main\assets

// create the "index.android.bundle" file
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

// run the app on android device
react-native run-android

Hope to help someone 😉

My project runs in debug mode, but the release apk crashes. The logs have the same error -> Unable to load script from assets 'index.android.bundle'. What should I do to fix this?

The apk was generating fine, until today. I don’t see how I caused it.

@wuyunqiang: can you run adb reverse tcp:8081 tcp:8081 and try again?

I have spent hours trying to figure this issue out.

Accessing the development server worked locally and in the emulator’s browser. The only thing that did not work was accessing the development server in the app.

Starting with Android 9.0 (API level 28), cleartext support is disabled by default.

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest ...>
    <uses-permission android:name="android.permission.INTERNET" />
    <application
        ...
        android:usesCleartextTraffic="true"
        ...>
        ...
    </application>
</manifest>

See for more info: https://stackoverflow.com/a/50834600/1713216

this trick “creating assets folder etc” sucks , neither I can not use debugger nor hot reloading …

I have tried ALL the answers here, but none work at all. Including removing build folder, clearing watchman, running as sudo, etc.

Hi guys. I have the same issue. Here’s my logcat output:

screen shot 2018-04-24 at 2 56 15 pm

ok I run 1:rm -rf /usr/local/var/run/watchman/root-state 2:react-native start 3:will be ok.

@akshaysargar I updated to the latest RN 0.57 with the new metro bundler. then it worked

I have a problem on creating a release build, since today its not building correctly anymore (I dont know why):

  1. Task :app:bundleReleaseJsAndAssets successfully creates the index.android.bundle
PATH..../android/app/build/intermediates/assets/release/index.android.bundle
bundle: Done writing bundle output
bundle: Copying 196 asset files
bundle: Done copying assets
  1. but when I install the .apk release file, it is unable to load the bundle file. Because its not in the apk. also the assets (images) are not in the .apk. How can this happen?

@wuyunqiang: move your issue to stackoverflow because this not a bug report and you will get much more chances of help in there.

Yes updated RN to 0.57.5 and finally it worked !!! This issue took me few days to solve it. I was working on RN 0.55.4 initially but was cautiously updating the RN as I had to take care of lot of dependencies. So just to inform, this issue that we are solving occurs on versions 0.56.0, 0.57.0 but finally I updated to the latest version 0.57.5 and that worked. Thanks @phips28, @mtkopone, @rgaraev

I caused this to myself by upgrading the gradle to com.android.tools.build:gradle:3.2.1. And that was because of trying to integrate firebase. Solved by upgrading RN to the latest version.

@phips28 , @km16 did you guys get any solution? My app works fine on physical device when debugging over USB but the release apk crashes. Also this issue appeared for me after doing the react-native-firebase configuration. The major configurations done are in this link below https://rnfirebase.io/docs/v5.x.x/installation/android

@km16 i fixed this. i use android studio ,not eclipse. assets dir in android studio is android/app/assets,however, in eclipse is android/app/src/main/assets . So move index.android.bundle index.android.bundle.meta from android/app/src/main/assets to android/app/assets. it works for me. post

If you work on the Windows, you should run 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 with cmd run as administrator(İmportant). Thus the problem was fixed 😃