gradlew assembleRelease and gradlew assembleReleaseStaging producing APK without changes

Viewed 899

I am trying to bundle my APK. When I use gradlew assembleRelease or assembleReleaseStaging there are no changes in my app. When I use 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 before assembling it creates a lot of new files, if i delete all of them except index.android.bundle and run gradlew assembleRelease or gradlew assembleReleaseStaging everything works just fine. My question is - is there any way to assemble release without manual bundling? I have tried gradlew clean and other ways found on stackoverflow. Any advice is highly appreciated.

1 Answers

You need to hook react.gradle to your module's build.gradle. Go to app/build.gradle and add the following:

// Configures the bundleJS commands for React-Native
project.ext.react = [

    // whether to bundle JS and assets in debug mode
    bundleInDebug: false,
    // whether to bundle JS and assets in release mode
    bundleInRelease: true, 

    // the root of your RN project, i.e. where "package.json" lives
    root: "path_to_rn_project_directory"
]
apply from: "<path to RN project>/node_modules/react-native/react.gradle"

After this, assembleRelease will start bundling as well.

Related