Unable to load script from assets 'index.android.bundle'.

I also got this and I resolved this using following commands in your project directory:

$ mkdir android/app/src/main/assets

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

$ react-native run-android

Using npm version 4.3.0 react-native-cli version 2.01 react-native version 0.49.5

In project directory,

  • mkdir android/app/src/main/assets
  • 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
  • react-native run-android

The file name has changed from index.android.js to index.js


For this error :

unable to load script from assets 'index.android.bundle'

1) Check for "assets" folder at :

mkdir android\app\src\main\assets

If the folder is not available, create a folder with name "assets" manually. and execute the Curl command in terminal.

2). Curl command:

curl "http://localhost:8081/index.android.bundle?platform=android" -o"android/app/src/main/assets/index.android.bundle"

It will create the "index.android.bundle" file in assets folder automatically and resolved the issue.

3) Then:

 react-native run-android

In my case (embedding React Native as a new Activity into an existing Android Code Base), the problem was Android Studio had auto-imported the wrong BuildConfig.

Wrong: import com.facebook.react.BuildConfig;

Right: import com.mywebdomain.myapp.BuildConfig;

This would apply to the wherever you are housing this block of code:

mReactRootView = new ReactRootView(this);
mReactInstanceManager = ReactInstanceManager.builder()
        .setApplication(getApplication())
        .setBundleAssetName("index.android.bundle")
        .setJSMainModulePath("index")
        .addPackage(new MainReactPackage())
        .setUseDeveloperSupport(BuildConfig.DEBUG)
        .setInitialLifecycleState(LifecycleState.RESUMED)
        .build();

Tags:

React Native