From b11f5486b1422afa8c29999619bdc54c3f78bc23 Mon Sep 17 00:00:00 2001 From: Jakob Malmo Date: Tue, 5 May 2026 00:01:13 +0200 Subject: [PATCH] fix: Detect newArchEnabled at subproject scope on Android `isNewArchitectureEnabled()` in react-native-nitro-modules, the Nitrogen module template and both internal test packages 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` instead sets `newArchEnabled=true` on each subproject's extraProperties. The rootProject-scoped check therefore returns false in that scenario, the libraries silently skip `apply plugin: "com.facebook.react"`, no codegen tasks register, and the consumer app fails at `:app:configureCMakeDebug` with: CMake Error at .../Android-autolinking.cmake: add_subdirectory given source ".../node_modules/react-native-nitro-modules/android/build/generated/source/codegen/jni/" which is not an existing directory. This was previously reported in #1031 (closed without identifying the root cause). 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 `build-android.yml`; with it the build is green. --- example/android/app/build.gradle | 2 +- example/android/gradle.properties | 7 ------- packages/react-native-nitro-modules/android/build.gradle | 2 +- .../react-native-nitro-test-external/android/build.gradle | 2 +- packages/react-native-nitro-test/android/build.gradle | 2 +- packages/template/android/build.gradle | 2 +- 6 files changed, 5 insertions(+), 12 deletions(-) diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 3ee84a4eb..7c61a46b7 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -73,7 +73,7 @@ def enableProguardInReleaseBuilds = true def jscFlavor = 'org.webkit:android-jsc:+' def isNewArchitectureEnabled() { - return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true" + return project.hasProperty("newArchEnabled") && project.getProperty("newArchEnabled") == "true" } logger.warn("Building with newArchEnabled = ${isNewArchitectureEnabled()}...") diff --git a/example/android/gradle.properties b/example/android/gradle.properties index 9afe61598..788b31519 100644 --- a/example/android/gradle.properties +++ b/example/android/gradle.properties @@ -27,13 +27,6 @@ android.useAndroidX=true # ./gradlew -PreactNativeArchitectures=x86_64 reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64 -# Use this property to enable support to the new architecture. -# This will allow you to use TurboModules and the Fabric render in -# your application. You should enable this flag either if you want -# to write custom TurboModules/Fabric components OR use libraries that -# are providing them. -newArchEnabled=true - # Use this property to enable or disable the Hermes JS engine. # If set to false, you will be using JSC instead. hermesEnabled=true diff --git a/packages/react-native-nitro-modules/android/build.gradle b/packages/react-native-nitro-modules/android/build.gradle index e36e0cde0..5488efe03 100644 --- a/packages/react-native-nitro-modules/android/build.gradle +++ b/packages/react-native-nitro-modules/android/build.gradle @@ -17,7 +17,7 @@ def reactNativeArchitectures() { } def isNewArchitectureEnabled() { - return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true" + return project.hasProperty("newArchEnabled") && project.getProperty("newArchEnabled") == "true" } apply plugin: "com.android.library" diff --git a/packages/react-native-nitro-test-external/android/build.gradle b/packages/react-native-nitro-test-external/android/build.gradle index 546fb8d0c..6f69d8bb1 100644 --- a/packages/react-native-nitro-test-external/android/build.gradle +++ b/packages/react-native-nitro-test-external/android/build.gradle @@ -15,7 +15,7 @@ def reactNativeArchitectures() { } def isNewArchitectureEnabled() { - return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true" + return project.hasProperty("newArchEnabled") && project.getProperty("newArchEnabled") == "true" } apply plugin: "com.android.library" diff --git a/packages/react-native-nitro-test/android/build.gradle b/packages/react-native-nitro-test/android/build.gradle index 766ffc1d8..7c41ea314 100644 --- a/packages/react-native-nitro-test/android/build.gradle +++ b/packages/react-native-nitro-test/android/build.gradle @@ -15,7 +15,7 @@ def reactNativeArchitectures() { } def isNewArchitectureEnabled() { - return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true" + return project.hasProperty("newArchEnabled") && project.getProperty("newArchEnabled") == "true" } apply plugin: "com.android.library" diff --git a/packages/template/android/build.gradle b/packages/template/android/build.gradle index a10f730cd..58025894d 100644 --- a/packages/template/android/build.gradle +++ b/packages/template/android/build.gradle @@ -15,7 +15,7 @@ def reactNativeArchitectures() { } def isNewArchitectureEnabled() { - return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true" + return project.hasProperty("newArchEnabled") && project.getProperty("newArchEnabled") == "true" } apply plugin: "com.android.library"