react.gradle does not support custom release build types (name not including "release")
See original GitHub issueDescription
We have several Android release build types, defined in our android/app/build.gradle
. They have other names than Release, of course. Like “Staging”.
The problem with react.gradle
is that it has multiple checks for isRelease
that only consider the target name, like here:
https://github.com/facebook/react-native/blob/164e133a98fade1c0f7577476e411bf9f6c2b7ca/react.gradle#L330
As a consequence of this, Hermes sourcemaps are not built for these release variants, as hermesFlagsDebug
is used, not hermesFlagsRelease
: https://github.com/facebook/react-native/blob/164e133a98fade1c0f7577476e411bf9f6c2b7ca/react.gradle#L189
Maybe one could instead use "config.bundleIn${targetName}"
and/or config."devDisabledIn${targetName}"
to check if a target is a release variant?
React Native version:
0.63.4
Steps To Reproduce
Provide a detailed list of steps that reproduce the issue.
- Add another buildType block to
android/app/build.gradle
called “Staging”. Something like this:
initWith(buildTypes.release)
applicationIdSuffix ".staging"
matchingFallbacks = ['release']
}
- Configure Staging for release in
project.ext.react
:
project.ext.react = [
devDisabledInRelease : true,
bundleInRelease : true,
devDisabledInStaging : true,
bundleInStaging : true,
- Add some logging to
node_modules/react-native/react.gradle
to check the evaluation ofisRelease
def isRelease = targetName.toLowerCase().contains("release")
+println "isRelease? ${isRelease}"
- Build the app with gradle and check the logs
cd android
./gradlew assembleStaging
Expected Results
I expect other release variants to also be treated as the one called Release.
Snack, code example, screenshot, or link to a repository:
Simplified and redacted. We use Yarn Workspaces (monorepo) so paths might look weird.
android/app/build.gradle
:
project.ext.react = [
root : "../..",
cliPath : "../../node_modules/react-native/cli.js",
bundleConfig : "metro.config.js",
composeSourceMapsPath: "../../node_modules/react-native/scripts/compose-source-maps.js",
hermesCommand : "../../../../node_modules/hermes-engine/%OS-BIN%/hermesc",
entryFile : "index.ts",
enableHermes: true, // clean and rebuild if changing
environmentForRelease: "prod",
devDisabledInRelease : true,
bundleInRelease : true,
environmentForStaging: "staging",
devDisabledInStaging : true,
bundleInStaging : true,
]
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
}
staging {
initWith(buildTypes.release)
applicationIdSuffix ".staging"
matchingFallbacks = ['release']
}
Issue Analytics
- State:
- Created 3 years ago
- Reactions:10
- Comments:7 (2 by maintainers)
Top GitHub Comments
If this is a valid approach, I would happily submit a PR
@draperunner You saved my day!
We have a react native project within a monorepo. I was having a lot of issues with the wrong
node/modules
path ofhermes
andcompose-source-maps
while building the app.If there is anyone having issues with monorepo project while building the app, you can configure the paths as below:
Thanks a lot again!