Skip to content

fix: Windows CMake/Ninja paths issue + Gradle 9 bundle/codegen ordering for barcode-scanner#3850

Open
AliRezaBeigy wants to merge 1 commit into
mrousavy:mainfrom
AliRezaBeigy:main
Open

fix: Windows CMake/Ninja paths issue + Gradle 9 bundle/codegen ordering for barcode-scanner#3850
AliRezaBeigy wants to merge 1 commit into
mrousavy:mainfrom
AliRezaBeigy:main

Conversation

@AliRezaBeigy
Copy link
Copy Markdown

Summary

Improves react-native-vision-camera-barcode-scanner Android builds on Windows and with Gradle 9 / React Native New Architecture by relocating native/Gradle outputs under the host app’s standard android/build/ tree (no extra top-level folders), and by declaring an explicit task ordering between Hermes bundle tasks and this library’s codegen output.

Problem

  1. Long paths on Windows
    The library often resolves under a deep node_modules/... tree. Android Gradle Plugin still places CMake/Ninja output in a .cxx tree derived from the module location, so object file paths can exceed practical Ninja/CMake limits. Symptoms include CMake repeatedly re-running and:
    ninja: error: manifest 'build.ninja' still dirty after 100 tries.

  2. Gradle 9 configuration validation
    With New Architecture enabled, :app:createBundle*JsAndAssets can consume outputs from :react-native-vision-camera-barcode-scanner:generateCodegenArtifactsFromSchema without an explicit dependency, which Gradle 9 reports as a misconfiguration.

Solution

  • Windows only (detected via os.name):

    • Set project.buildDir to android/build/externalNativeModules/<sanitized-project-name> (under rootProject.buildDir), so library outputs stay in the normal Gradle build output tree.
    • Set externalNativeBuild.cmake.buildStagingDirectory to ${project.buildDir}/cxx so CMake/Ninja staging is short and colocated with that module’s relocated buildDir.
  • All platforms (when the React Gradle plugin registers codegen on this project):

    • In gradle.projectsEvaluated, find generateCodegenArtifactsFromSchema on this project and register dependsOn from every application subproject’s createBundle*JsAndAssets tasks.

Notes

  • Does not add -DCMAKE_OBJECT_PATH_MAX=...: Android SDK CMake is often 3.22.x, while that flag targets CMake 3.26+; relocation addresses the root cause without relying on newer CMake.
  • Uses rootProject.buildDir so paths stay correct for the usual React Native layout where the Gradle root is the android/ project.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 9, 2026

@AliRezaBeigy is attempting to deploy a commit to the Margelo Team on Vercel.

A member of the Team first needs to authorize it.

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