9

After upgrade to 0.59 the development build fails with the following error. It worked fine till 0.58.6

"Unable to load script. Make sure you're either running a Metro server (run 'react-native start') or that your bundle is packaged correctly for release."

I have also added android:usesCleartextTraffic="true" in AndroidManifest.xml but it still won't work. The release build works fine though.

Ehsan
  • 151
  • 1
  • 7
  • try to clean run `./gradlew clean` from android folder once to clean up previous builds and run again – warl0ck Mar 18 '19 at 06:16
  • Have tried that already, have even cleared node_modules folder but it still won't work. – Ehsan Mar 18 '19 at 06:18
  • is this the release version you are trying or development version ? if development is metro packager bundle terminal started when you run the command ? – warl0ck Mar 18 '19 at 06:20
  • Its the development version i am trying to build and yes metro package bundler starts correctly but got stuck at "Loading dependency graph..." – Ehsan Mar 18 '19 at 06:24
  • I had the same issue , this link removed my problem : https://stackoverflow.com/questions/55441230/unable-to-load-script-make-sure-you-are-either-running-a-metro-server-or-that-yo/59022921#59022921 – Abolfazl Roshanzamir Nov 24 '19 at 22:13

3 Answers3

8

You need to change your target sdk to 27 instead of 28 in your project level build.gradle. From Android P(28), Google ban the use of http.

enter image description here

Cà phê đen
  • 1,883
  • 2
  • 21
  • 20
  • Have tried it now with sdk 27, still throwing the same error. – Ehsan Mar 18 '19 at 15:07
  • @Ehsan - did you run gradle clean and resync your gradle files after the change to the sdk target? – powerup7 Mar 18 '19 at 22:19
  • @powerup7 yes, have cleared the gradle cache and other stuff but it is still showing the same error. I also created a new RN project just to test and it throws the same error. There seems to be some issue with 0.59 version – Ehsan Mar 19 '19 at 04:28
  • @Ehsan trying running `npm run start --reset-cache` to clear your cache. If it doesn't work then you need to bundle an bundle file for android offline. – powerup7 Mar 20 '19 at 00:46
  • I encountered the same issue... did anyone solved it ? using 0.59.1 – Arigui Ahmed Mar 20 '19 at 14:12
  • Is this resolved ? I am also getting the same error. React native version that I am using is 0.59.3. – TheHound.developer Apr 04 '19 at 09:40
  • Follow this link and add ANDROID_HOME properly. It will work. https://stackoverflow.com/questions/26356359/error-android-home-is-not-set-and-android-command-not-in-your-path-you-must – TheHound.developer Apr 04 '19 at 10:45
0

I had this same issue using genymotion and then I realized that the emulator was offline, and that's why it couldn't connect to the metro server.

Tino
  • 11
  • 3
0

"react-native": "0.64.1",

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

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

]

Mahmonir Bakhtiyari
  • 546
  • 1
  • 8
  • 21