Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to load script. Make sure you are either running a Metro server or that your bundle 'index.android.bundle' is packaged correctly for release

I created a new project with react-native init . I am using react-native with the following:"react": "16.13.1","react-native": "0.63.2".

When i am trying to run the app with react-native run-android command it shows build successful in the terminal but nothing appears in my metro bundler(I am attaching the image of it) and my emulator shows the 'Unable to load script' issue. Unable to load script

If I press 'R' to reload the app in node(bundler) it says there is no device attached to it but my emulator is running. I encountered the same problem with personal device also. metro bundler not running

I also tried by creating the assets folder in android/app/src/main/assets and run the below 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.

With this only once the app gets displayed on the emulator and when I make changes in the App.js file and save it there is no change in the emulator.

If I reload the error "Could not connect to the development server" pops up. could not connect to development server Even tried the adb reverse and changing 'dev' options to local host and port 8081, but it was not useful. (If there is any specific path where I should try the above steps please mention).

What is that I have done wrong?

Can anyone help please.

P.S.: I am using a windows 10 machine.

Thank you.

like image 212
Anjali Neela Avatar asked Jul 23 '20 12:07

Anjali Neela


People also ask

What is Metro server in react native?

Metro is a development platform for React Native. This project acts as a JavaScript bundler; it manages assets, caches builds and performs hot module reloading. Metro focuses on improving the developer experience for the React Native community.


Video Answer


1 Answers

"react-native": "0.64.1",

I used other solution but I've resolved this issue in other way. I resolved it by changing bundleInDebug: true, in project.ext.react in android > app > build.gradle.

project.ext.react = [
bundleInDebug: true,
enableHermes: ***,  

]

like image 75
Mahmonir Bakhtiyari Avatar answered Sep 27 '22 20:09

Mahmonir Bakhtiyari