I\'m trying to run my first React Native project for first time on my device (Android 4.2.2).
And I get:
unable to load script from assets in
don't forget turn on internet in emulator device, I resovled this error, it work perfect :V I get this error because i turn off internet to test NetInfo :D
If when running react-native run-android
command the second line of the trace is
JS server not recognized, continuing with build...
it means packager for the app cannot be started and the app will fail to load without some extra steps. Note that the end of the trace still reports success:
BUILD SUCCESSFUL
The problem is probably some port conflict (in my case it was the default IIS site that I completely forgot about). Another manifestation of the problem would be a failure to open http://localhost:8081/debugger-ui
URL in Chrome.
Once the port conflict is resolved the trace will report
Starting JS server...
then an additional Node window will open (node ...cli.js start
) and the app will load/reload successfully.
After that you should be able to open debug console in Chrome with http://localhost:8081/debugger-ui
.
Follow this, Worked for me.
https://github.com/react-community/lottie-react-native/issues/269
Go to your project directory and check if this folder exists android/app/src/main/assets i) If it exists then delete two files viz index.android.bundle and index.android.bundle.meta ii) If the folder assets doesn't exist then create the assets directory there.
From your root project directory do cd android && ./gradlew clean
Finally, navigate back to the root directory and check if there is one single entry file called index.js i) If there is only one file i.e. index.js then run following command 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
ii) If there are two files i.e index.android.js and index.ios.js then run this 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
Now run react-native run-android
I've encountered the same issue while following the React Native tutorial (developing on Linux and targeting Android).
This issue helped me resolve the problem in following steps.
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
You can automate the above steps by placing them in scripts
part of package.json
like this:
"android-linux": "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"
Then you can just execute npm run android-linux
from your command line every time.
Had the same issue in mac, After spending 2 days i was finally able to get is working.
Since Emulator cellular data was turned off
, I was getting the unable to load script from assets index.android.bundle make sure your bundle is running
.
Make sure your Emulator cellular data is turned on
by doing this package server was able to bundle index.android.js
. Hope it helps for someone who is in development phase.
I had the same issue even when running on a simulator. I did a quick workaround so that I could have the normal dev workflow.
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
// return true here to load JS from the packager
// BuildConfig.DEBUG for me was set to false which meant it
// it was always trying to load the assets from assets folder.
return true;
}
@Override
protected String getJSMainModuleName() {
return "index";
}
};
Probably will have to revert the change when trying to do a production build.