Skip to content

fix(android): restore namespace fallback for libraries not applying the React plugin#57290

Draft
cortinico wants to merge 2 commits into
mainfrom
nc/configureNamespaceForLibraries
Draft

fix(android): restore namespace fallback for libraries not applying the React plugin#57290
cortinico wants to merge 2 commits into
mainfrom
nc/configureNamespaceForLibraries

Conversation

@cortinico

Copy link
Copy Markdown
Contributor

Summary:

#57038 narrowed configureNamespaceForLibraries from a rootProject-wide sweep to only the project applying com.facebook.react. That was necessary because the old code re-ran the sweep from every library, and AGP 9 errors when finalizeDsl is registered after a project's DSL has been finalized.

The narrowing has a side effect: third-party Android libraries that do NOT apply com.facebook.react and still rely on the manifest package attribute (e.g. older react-native-linear-gradient) no longer receive a namespace, so they fail under AGP 9 with "Namespace not specified".

Restore the broad coverage by sweeping all com.android.library subprojects once, from the application project (which applies the plugin a single time, avoiding the repeated-traversal finalizeDsl error from #57038). Guard configureNamespaceForLibraries so it registers its finalizeDsl callback at most once per project, since libraries that DO apply the React plugin are now reachable from both the per-library hook and the app-level sweep.

Changelog:

[INTERNAL] - restore namespace fallback for libraries not applying the React plugin

Test Plan:

CI

…he React plugin

#57038 narrowed configureNamespaceForLibraries from a rootProject-wide sweep to
only the project applying `com.facebook.react`. That was necessary because the old
code re-ran the sweep from every library, and AGP 9 errors when `finalizeDsl` is
registered after a project's DSL has been finalized.

The narrowing has a side effect: third-party Android libraries that do NOT apply
`com.facebook.react` and still rely on the manifest `package` attribute (e.g. older
react-native-linear-gradient) no longer receive a namespace, so they fail under
AGP 9 with "Namespace not specified".

Restore the broad coverage by sweeping all `com.android.library` subprojects once,
from the application project (which applies the plugin a single time, avoiding the
repeated-traversal finalizeDsl error from #57038). Guard configureNamespaceForLibraries
so it registers its finalizeDsl callback at most once per project, since libraries
that DO apply the React plugin are now reachable from both the per-library hook and
the app-level sweep.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 19, 2026
The app-level namespace sweep registered a `finalizeDsl` callback on every
`com.android.library` subproject. In composite/monorepo builds (e.g. rn-tester,
where ReactAndroid is a sibling library) some library projects are already
evaluated — and their AGP DSL already finalized — by the time the app applies
the sweep, so registering `finalizeDsl` on them fails on AGP 9 with
"It is too late to call finalizeDsl".

Guard the sweep with `!subproject.state.executed`: only configure projects that
haven't been evaluated yet (for which `finalizeDsl` is still valid). In a regular
app build the app is evaluated before its libraries (ReactRootProjectPlugin's
`evaluationDependsOn(":app")`), so all libraries are still pending and covered.
Already-evaluated projects in monorepo builds define their own namespace, so
skipping them is safe.

Verified against rn-tester: `:packages:rn-tester:android:app:assembleDebug
--dry-run` reproduces the crash without this guard and succeeds with it.
@cortinico cortinico marked this pull request as draft June 19, 2026 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant