Skip to content

Read the entry point's BuildConfig from the app's own namespace - #60381

Closed
ide wants to merge 1 commit into
react:mainfrom
expo:@ide/gradle-entry-point-app-namespace
Closed

ide wants to merge 1 commit into
react:mainfrom
expo:@ide/gradle-entry-point-app-namespace

Conversation

@ide

@ide ide commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Summary:

generateReactNativeEntryPoint writes ReactNativeApplicationEntryPoint, which reads <package>.BuildConfig.IS_NEW_ARCHITECTURE_ENABLED and IS_EDGE_TO_EDGE_ENABLED. The task takes the package from project.android.packageName in the autolinking config, which describes one application. In a build with two applications that apply the React plugin, the second application's entry point names the first application's BuildConfig, which is not on its classpath, so the second application does not compile.

AGP generates BuildConfig in the application's namespace. This change passes the namespace to the task, which uses it when it is set. The config's package name remains the fallback, so a build that does not set the property behaves as before.

GeneratePackageListTask also takes the package name from the config, to expand BuildConfig and R in a library's packageInstance. This change does not touch it.

Changelog:

[ANDROID] [FIXED] - Generate the React Native entry point against the app's own namespace, so a build can hold two apps

Test Plan:

GenerateEntryPointTaskTest gains two tests of taskAction: with applicationNamespace set, the generated file reads BuildConfig from that namespace and does not mention the config's package; without it, the file reads BuildConfig from the config's package.

./gradlew -p packages/gradle-plugin :react-native-gradle-plugin:test --tests com.facebook.react.tasks.GenerateEntryPointTaskTest --max-workers=4 --console=plain
  • With the task changed back to ignore applicationNamespace: taskAction_withApplicationNamespace_readsBuildConfigFromIt fails.
  • With the fix: 5 tests pass.

Also run: ktfmt --dry-run --set-exit-if-changed on the three changed Kotlin files (clean), git diff --check (clean).

The whole plugin suite (./gradlew -p packages/gradle-plugin test) on this branch: 249 tests, 248 pass. The one failure, PreparePrefabHeadersTaskTest.preparePrefabHeadersTask_declaresTheHeadersItCopiesAsInputs, fails the same way on main on macOS, where the test's temporary directory resolves through /private/var (#60375 fixes it).

Not run: no test covers the line in ReactPlugin that reads the namespace from ApplicationExtension, and no Android build with one or two applications was run with this branch.

🤖 Generated with Claude Code

`generateReactNativeEntryPoint` writes a class that reads
`<package>.BuildConfig`, and takes the package from
`project.android.packageName` in the autolinking config. The config
describes one application. In a build with two applications that apply
the React plugin, the second application's entry point names the first
application's `BuildConfig`, which is not on its classpath, so it does
not compile.

AGP generates `BuildConfig` in the application's `namespace`
(https://developer.android.com/build/configure-app-module#set-namespace),
so pass that to the task and use it when it is set. The config's
package name remains the fallback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@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 Nov 29, 2026
@github-actions github-actions Bot added the Meta Review Required This PR is considered risky and requires Meta to import it to do more testing before merging. label Nov 29, 2026
@github-actions

Copy link
Copy Markdown

Visual regression

No visual differences at cf48ca3a5a3e.

ios: no capture

@ide

ide commented Nov 29, 2026

Copy link
Copy Markdown
Contributor Author

Closing: this only matters for a build that holds two React Native apps, which isn't a setup React Native supports. The change stays in Expo's fork, with the app that needs it.

@ide ide closed this Nov 29, 2026
@ide
ide deleted the @ide/gradle-entry-point-app-namespace branch November 29, 2026 21:30
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. Meta Review Required This PR is considered risky and requires Meta to import it to do more testing before merging.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant