Unable to load script. Make sure you're either running a metro server or that your bundle 'index.android.bundle' is packaged correctly for release
Asked Answered
X

6

7

enter image description here

Hello have you experienced this error after generate an apk with command ./gradlew assembleDebug ??

I just see this error after download the apk on my android phone...

"react-native": "~0.61.5",

Xeres answered 15/5, 2020 at 19:50 Comment(0)
A
7

The apk that you built is still debug version.

./gradlew assembleDebug

Thats why it still need the metro server to debug and run normally.

If you want to test out a release version of the apk you need to build and run the apk in release mode:

Either, build a signed apk https://reactnative.dev/docs/signed-apk-android or

Let react native run a release variant on your device(you may still need metro server)

react-native run-android --variant=release

If the above command doesn't work try:

react-native run-android --configuration=release
Aliunde answered 15/5, 2020 at 21:2 Comment(1)
This is the real answer. ThanksTheadora
E
2

Recently I tried to create and run in windows 10 by referring the link https://reactnative.dev/docs/environment-setup. I too face same issue and I figure out that this is because by default mobile device try to search build in port 8081. So I gave this command to change the port and run npx react-native run-android --port=1234 and it worked.

Edouard answered 4/3, 2021 at 13:46 Comment(0)
P
1

npx react-native run-android --port=1234

go to android folder ./gradlew clean

and go back to your project

and npx run react-native run-android

Popular answered 9/11, 2021 at 8:27 Comment(0)
P
0

I had to add the Android SDK path to my .bash_profile or .zshrc:

export ANDROID_SDK=/Users/<username>/Library/Android/sdk export PATH=/Users/<username>/Library/Android/sdk/platform-tools:$PATH

Progeny answered 26/7, 2020 at 21:21 Comment(0)
N
0

I was facing this problem because I was not starting the Reactive Native service itself.

You can run directly:

react-native start

Metro will give you the option to run on Android.

Noreennorene answered 2/4, 2023 at 12:12 Comment(0)
I
0

Beginner in React Native :- For me, I am getting this error because it seems like the build script is looking assets folder inside the Android project.

So, I just created the folder: mkdir android/app/src/main/assets

and ran the command: npx 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 --verbose

And then when I run npx react-native run-android: I can see my app.js content on android emulator. Woohoo! However, now I am trying to figure out, why are the changes not live! I can see the changes in App.js reflect immediately on iOS simulator, but not on Android emulator. But that should be a seperate thread altogether.

Irishirishism answered 2/7 at 5:53 Comment(1)
This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. To get notified when this question gets new answers, you can follow this question. Once you have enough reputation, you can also add a bounty to draw more attention to this question. - From ReviewTonus

© 2022 - 2024 — McMap. All rights reserved.