Skip to content

fix(android-player): remove unused codegen block causing Android build failure#223

Open
kherembourg wants to merge 6 commits intomainfrom
fix/android-player-codegen-src-missing
Open

fix(android-player): remove unused codegen block causing Android build failure#223
kherembourg wants to merge 6 commits intomainfrom
fix/android-player-codegen-src-missing

Conversation

@kherembourg
Copy link
Contributor

Problem

Users building Android apps with @purchasely/react-native-purchasely-android-player get a build failure:

Task :purchasely_react-native-purchasely-android-player:generateCodegenSchemaFromJavaScript FAILED
Error: ENOENT: no such file or directory, lstat '.../node_modules/@purchasely/react-native-purchasely-android-player/src'

The build.gradle contained a react { jsRootDir = file("../src/") } block that instructs React Native codegen to scan the src/ directory during Android builds. However, the src/ folder is not included in the published npm package (it's absent from the files field in package.json), so the directory doesn't exist in node_modules — causing an immediate crash.

Root cause

The codegen block was vestigial. The package uses NativeModules (old architecture bridge) with no Turbo Module specs — codegen has nothing to generate from src/ anyway. The block was never needed and actively broke builds.

Fix

Remove the dead code entirely:

  • def isNewArchitectureEnabled() helper function
  • if (isNewArchitectureEnabled()) { apply plugin: 'com.facebook.react' }
  • if (isNewArchitectureEnabled()) { react { jsRootDir = ... } } block
  • IS_NEW_ARCHITECTURE_ENABLED build config field (unused in source code)

No functional change — the package never used codegen.

Affected versions

All published versions (confirmed on 5.2.0 and 5.7.0).

Related

Reported by @nicost71 in #213.

Test plan

  • 139/139 TypeScript/Jest tests pass
  • Lint passes
  • CI: Android build passes without src/ directory workaround

🤖 Generated with Claude Code

The `react { jsRootDir = file("../src/") }` block in build.gradle
triggered React Native codegen to look for a `src/` directory that
is not included in the published npm package, causing Android builds
to fail with ENOENT on `generateCodegenSchemaFromJavaScript`.

Since android-player has no Turbo Module specs (it uses NativeModules,
the old architecture bridge), the codegen block was both unnecessary
and broken. Removing it and the related `isNewArchitectureEnabled()`
helper fixes the build for all consumers without any loss of
functionality.

Fixes: #213 (comment)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical Android build failure experienced by users of the @purchasely/react-native-purchasely-android-player package. The issue stemmed from an outdated and unnecessary React Native codegen configuration that attempted to access a non-existent source directory within the published npm package. By systematically removing this problematic configuration and related new architecture checks, the PR ensures that Android applications can build successfully without encountering the previous ENOENT error, thereby improving the developer experience and stability of the library.

Highlights

  • Android Build Fix: Resolved an Android build failure occurring in @purchasely/react-native-purchasely-android-player by removing an unused codegen block.
  • Root Cause Identified: The build failure was caused by a vestigial react { jsRootDir = file("../src/") } block in build.gradle that instructed React Native codegen to scan a src/ directory which is not included in the published npm package.
  • Code Cleanup: Removed the isNewArchitectureEnabled() helper function, the conditional application of com.facebook.react plugin, the IS_NEW_ARCHITECTURE_ENABLED build config field, and the entire react { ... } codegen block, as the package uses NativeModules and does not require codegen.
  • No Functional Change: The changes are purely for build stability and do not alter the package's functionality, as the removed codegen block was never actively used.
Changelog
  • packages/android-player/android/build.gradle
    • Removed the isNewArchitectureEnabled() helper function.
    • Removed the conditional application of the com.facebook.react plugin.
    • Removed the IS_NEW_ARCHITECTURE_ENABLED build config field.
    • Removed the react { ... } codegen block, including jsRootDir and libraryName configurations.
Activity
  • The problem was reported by @nicost71 in issue chore: migrate to React Native 0.83 #213.
  • The author, kherembourg, has confirmed that 139/139 TypeScript/Jest tests pass.
  • The author has confirmed that lint checks pass.
  • A CI check for Android build passing without the src/ directory workaround is pending.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request resolves an Android build failure by removing unused code related to React Native's new architecture from the android-player's build.gradle file. The changes correctly remove the isNewArchitectureEnabled checks and the associated react block that was causing the build to fail by referencing a non-existent src/ directory. The fix is well-contained and directly addresses the root cause described in the pull request.

kherembourg and others added 5 commits February 27, 2026 23:24
…e turbo env

gradle.properties used PurchaselyGoogle_ prefix while build.gradle reads
PurchaselyAndroidPlayer_ — causing NPE on standalone builds.

turbo.json declared ORG_GRADLE_PROJECT_newArchEnabled (removed with the
codegen block) and a build:ios task irrelevant for this Android-only package.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
For all four satellite packages (android-player, google, amazon, huawei):

- AGP: 7.3.1 → 8.7.3 (aligns with main purchasely package)
- Java/Kotlin: VERSION_1_8 → VERSION_11, add kotlinOptions jvmTarget=11
- Add namespace declaration to android{} block (required by AGP 8+)
- Replace dead 64-line RN source-lookup block with google()/mavenCentral()
  The lookup was superseded by RNGP in RN 0.71; confirmed present in
  example/android/settings.gradle
- Remove jcenter() (shut down Feb 2022)
- Keep mavenLocal() in buildscript repos for local library development
- Preserve Huawei-specific Maven repo and agcp classpath in huawei package

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- source field: ./src/index.tsx → ./src/index.ts (file has no JSX)
- repository.url: packages/google → packages/android-player (copy-paste leftover)
- homepage: same correction

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…Script API

All four satellite packages (android-player, google, amazon, huawei) exported
a multiply(a, b) function that was leftover from the React Native library
template. These packages function as native dependency carriers — they bring
in store-specific Gradle dependencies. No JavaScript API is needed.

Also fixes huawei/src/index.ts which incorrectly referenced PurchaselyGoogle
instead of PurchaselyHuawei.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…et mismatch

With AGP 8 and JDK 17 in CI, javac targets 17 while kotlinOptions jvmTarget=11
caused: "Inconsistent JVM-target compatibility (17 vs 11)".

Remove explicit jvmTarget — AGP automatically aligns Kotlin to match the
Java compileOptions target, consistent with the main purchasely package.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

1 participant