Search code examples
androidreact-nativeapk

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


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",


Solution

  • 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