Search code examples
androidreact-nativemetro-bundler

compiled apk is trying to reach metor server react native


I don't know really why my compiled apk is trying to reach metor server

I am creating a iOS / android app using react-native

The build was working before

cd android/
./gradlew assembleRelease --stacktrace

Generated in android/app/build/outputs/apk/release

enter image description here


Solution

  • Error showing your metro bundle is not found. You need to create bundle using 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
    

    Other way to create release build

    1. Place the my-release-key.keystore file under the android/app directory in your project folder

    2. Edit the file ~/.gradle/gradle.properties  and add the following (replace ***** with the correct keystore password, alias and key password

    MYAPP_RELEASE_STORE_FILE=my-release-key.keystore MYAPP_RELEASE_KEY_ALIAS=my-key-alias MYAPP_RELEASE_STORE_PASSWORD=***** MYAPP_RELEASE_KEY_PASSWORD=*****

    1. Edit the file android/app/build.gradle in your project folder and add the signing config

      android { defaultConfig { ... } signingConfigs { release { storeFile file(MYAPP_RELEASE_STORE_FILE) storePassword MYAPP_RELEASE_STORE_PASSWORD keyAlias MYAPP_RELEASE_KEY_ALIAS keyPassword MYAPP_RELEASE_KEY_PASSWORD } } buildTypes { release { ... signingConfig signingConfigs.release } } } ...

    2. Run this command on terminal

      react-native run-android --variant=release

    https://facebook.github.io/react-native/docs/signed-apk-android