fix(android): detect newArchEnabled at subproject scope#8
Open
jmalmo wants to merge 1 commit into
Open
Conversation
`isNewArchitectureEnabled()` in `android/build.gradle` reads
`rootProject.hasProperty("newArchEnabled")`. On RN >= 0.82 with Expo SDK
55, the new architecture is mandatory and the property is no longer
required to live in `android/gradle.properties`; React Native's
`ReactRootProjectPlugin` sets `newArchEnabled=true` on each subproject's
`extraProperties` instead. The rootProject-scoped check therefore
returns false, the library skips `apply plugin: "com.facebook.react"`,
no codegen tasks register, and the consumer build fails at
`:app:configureCMakeDebug` with:
CMake Error at .../Android-autolinking.cmake:
add_subdirectory given source
".../node_modules/react-native-emoji-popup/android/build/generated/source/codegen/jni/"
which is not an existing directory.
Switch the helper to `project.hasProperty("newArchEnabled")`. That covers
both the RN >= 0.82 path (subproject extraProperties) and the legacy
explicit-opt-in path (`gradle.properties` values propagate to every
project), and keeps the `src/oldarch` source path viable for RN < 0.82.
Pin the regression by removing `newArchEnabled=true` from
`example/android/gradle.properties`. Without the helper change the
example app fails to build under `ci.yml`'s `build-android` job; with it
the build is green.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What I changed
I switched
isNewArchitectureEnabled()fromrootProject.hasProperty(...)toproject.hasProperty(...)inandroid/build.gradleand the example app's helper.I also dropped
newArchEnabled=truefromexample/android/gradle.propertiesto pin the regression — the existingbuild-androidjob inci.ymlnow exercises the same code path real consumers hit.Why
I hit this on a fresh React Native 0.83 / Expo SDK 55 dev-client app with
react-native-emoji-popupinstalled.bun androidfailed at:app:configureCMakeDebug[arm64-v8a]:After digging in: on RN >= 0.82 the new architecture is mandatory and
newArchEnabledis no longer required to live ingradle.properties. React Native'sReactRootProjectPlugininstead sets the property on each subproject'sextraProperties. The current rootProject-scoped check misses that path — the lib silently skipsapply plugin: "com.facebook.react", no codegen tasks register, and the consumer build dies during CMake configure. The same trap fires after a stale, non---cleanExpo prebuild where the existinggradle.propertiesstays put and never picks up the new template's content.project.hasProperty(...)covers all three cases without dropping legacy-arch support:ReactRootProjectPlugin's subprojectextraProperties.gradle.propertiesvalues propagate to every project, soproject.hasProperty(...)still returnstrue.src/oldarchsource path is preserved.I considered going the more aggressive route and deleting the gate entirely (mirroring callstack/react-native-pager-view#1047), but
peerDependenciesare still permissive (react-native: "*") andsrc/oldarchexists, so the conservative fix felt right. Happy to switch if you'd prefer the harder line.Test plan
The diff removes
newArchEnabled=truefromexample/android/gradle.properties, so the existingbuild-androidjob inci.ymlnow fails onmain(the lib skips codegen) and passes with this PR. I verified locally with the same command CI uses:Result:
BUILD SUCCESSFUL in 1m 45s.:react-native-emoji-popup:generateCodegenArtifactsFromSchemaregistered and ran,:app:configureCMakeDebug[arm64-v8a]completed, and:app:bundleDebugsucceeded.Other checks I ran:
yarn install— green.yarn typecheck— green.yarn lint— green (only pre-existing inline-style warnings inexample/src/App.tsx, untouched by this PR).yarn test— green (existing 1-todo Jest suite passes).yarn prepare(Bob build) implicitly verified via the build-library job equivalent duringyarn install.Notes
main. No spec/test removals, no unrelated edits.react-native-nitro-modules.