Skip to content

fix(android): apply codegen plugin unconditionally, not gated on isNewArchitectureEnabled - #4

Open
rohit-till wants to merge 2 commits into
rohit/publish-github-packagefrom
fix/codegen-newarch-gate
Open

fix(android): apply codegen plugin unconditionally, not gated on isNewArchitectureEnabled#4
rohit-till wants to merge 2 commits into
rohit/publish-github-packagefrom
fix/codegen-newarch-gate

Conversation

@rohit-till

Copy link
Copy Markdown
Collaborator

Summary

RN's Android autolinking discovers this module's codegen libraryName by regexing the raw text of android/build.gradle (findLibraryName.js in @react-native-community/cli-config-android) rather than evaluating this file's Groovy conditionals. So the consuming app's build always registers this module for codegen and expects android/build/generated/source/codegen/jni/ to exist — regardless of isNewArchitectureEnabled().

Because apply plugin: 'com.facebook.react' and the react { ... } codegen block here were gated behind isNewArchitectureEnabled(), a consuming app with newArchEnabled=false never actually ran this module's own codegen task, so that directory was never created. This produces a hard CMake configure failure for any consumer:

CMake Error at .../Android-autolinking.cmake:16 (add_subdirectory):
  add_subdirectory given source
  ".../react-native-esc-pos-printer/android/build/generated/source/codegen/jni/"
  which is not an existing directory

This also matters going forward regardless of that flag: RN 0.82+ no longer supports opting out of New Architecture (newArchEnabled is ignored and a warning is printed), so codegen must always run.

Change

Applies the com.facebook.react plugin and configures the react { } codegen extension unconditionally, matching how other actively-maintained RN modules declare codegen (they don't gate it on isNewArchitectureEnabled() either). No behavior change for consumers already on New Architecture; unblocks consumers on RN 0.82+/0.84+ where new arch is forced on.

Base branch note

Targeting rohit/publish-github-package rather than main: main has since diverged to a restructured package/ layout (a different major-version line) where android/build.gradle no longer exists at this path. rohit/publish-github-package is the actual lineage this org's v2.2.x releases (up to v2.2.4) are cut from, so this is the branch a v2.2.5-style patch release would come from.

Test plan

  • Verified that a consuming app with newArchEnabled=false (or on RN 0.82+/0.84+ where the flag is ignored) successfully runs generateCodegenArtifactsFromSchema for this module and configureCMakeDebug no longer fails with the add_subdirectory error above.

🤖 Generated with Claude Code

…wArchitectureEnabled

RN's autolinking discovers this module's codegen libraryName by regexing the
raw text of android/build.gradle (findLibraryName.js) rather than evaluating
this file's Groovy conditionals. So the app-level build always registers this
module for codegen and expects android/build/generated/source/codegen/jni/
to exist, regardless of isNewArchitectureEnabled().

Because `apply plugin: 'com.facebook.react'` and the `react { ... }` codegen
block were gated behind isNewArchitectureEnabled(), consuming apps with
newArchEnabled=false never actually ran this module's own codegen task, so
that directory was never created. This produces a hard CMake configure
failure for any consumer:

  CMake Error: add_subdirectory given source
  ".../react-native-esc-pos-printer/android/build/generated/source/codegen/jni/"
  which is not an existing directory

This is also unconditionally required going forward: RN 0.82+ no longer
supports opting out of New Architecture (newArchEnabled is ignored), so
codegen must always run regardless of that flag.

Applies the plugin and configures the react{} codegen extension
unconditionally, matching how other actively-maintained RN modules declare
codegen. No behavior change for consumers already on New Architecture.
@changeset-bot

changeset-bot Bot commented Sep 3, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 345ddc8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Sep 3, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Essentials

Run ID: 654620b4-230b-47a4-bc22-0d5218abcfc9

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

Minor bump rather than a patch: consuming apps now get a real behavior
change (codegen artifacts are always generated, not just when
newArchEnabled=true), not just a bugfix in the strict sense.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants