1

I'm newbie in RN. I have a problem with building release APK. I'm doing following steps:

  1. rm -rf node_modules & npm install
  2. Generating bundle:

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/
  1. cd android & ./gradlew assembleRelease

app/build.gradle:

project.ext.react = [
    entryFile: "index.js",
    bundleInDebug: true,
    bundleInRelease: true,
]

apply from: "../../node_modules/react-native/react.gradle"

....

It seems bundleInRelease option is not working properly. However ./gradlew assembleDebug works perfect! Please help!

Bakhrom Achilov
  • 157
  • 1
  • 2
  • 14
  • 3
    You just have to use assembleRelease. Bundling will happen itself. – Sanyam Jain Mar 08 '19 at 19:53
  • I have tried to use assembleRelease. But some functionality doesn't work and when I launch npm install on terminal it works well. However, when I'm building apk with assembleDebug everything works fine. – Bakhrom Achilov Mar 09 '19 at 04:22
  • 1
    What do you mean by "Some functionality doesn't work"? Are you proguarding your app? – Sanyam Jain Mar 09 '19 at 07:01
  • I used 'react-native-bitcoinjs-lib' library, as well as, I know there is no proguard rules. When I launch debug APK everything works fine, but on release APK I got following error: "Expected property '0' of type ECPair, got k" – Bakhrom Achilov Mar 09 '19 at 07:09
  • I noted that, when I set bundleInDebug: false I got similar error in debug apk. – Bakhrom Achilov Mar 09 '19 at 07:21
  • @BakhromAchilov : have you set up signing for your app? https://facebook.github.io/react-native/docs/signed-apk-android – Bhavesh Jariwala Mar 09 '19 at 10:01

1 Answers1

2

Solved!
I used 'react-native-bitcoinjs-lib' library and the thing is the library was not fully configured. By documentation, for generating release APK, additionally, I had to create file in project named metro.config.js. And wrote following code in it:

module.exports = {
    transformer: {
      minifierConfig: {
        mangle: {
          keep_fnames: true
        }
      }
    }
  }

Now, everything works fine.

Bakhrom Achilov
  • 157
  • 1
  • 2
  • 14