I'm new in react-native. I have run react native project on Ubuntu by using 'react-native run-android' command. And I got the error on emulator "Unable to load script from assets 'index.android.bundle'.Make sure your bundle is packaged correctly or you are running a package server."
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
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();
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With