Skip to content

[Android] GenerateAutolinkingNewArchitecturesFileTask still emits invalid add_subdirectory entries on 0.83.1 when JNI codegen dirs are missing #56334

Open

Description

@sagnik2001

Description

Description

This still reproduces for me on React Native 0.83.1 with New Architecture enabled.

The generated Android-autolinking.cmake contains unconditional
add_subdirectory(...) entries for JNI/codegen directories under dependencies, e.g.

node_modules/<package>/android/build/generated/source/codegen/jni/

During ./gradlew clean, some of those directories do not exist, and CMake fails with:

add_subdirectory given source ".../jni/" which is not an existing directory

This prevents clean/build from completing.

A local fix is to update
GenerateAutolinkingNewArchitecturesFileTask.kt
so generated CMake:

  • wraps add_subdirectory(...) with if(EXISTS ...)
  • only appends the library to AUTOLINKED_LIBRARIES if that directory was actually added

Steps to reproduce

  1. Enable New Architecture
  2. Install dependencies
  3. Run ./gradlew clean
  4. Observe failure in generated Android-autolinking.cmake

React Native Version

0.83.1

Affected Platforms

Build - MacOS, Runtime - Android

Areas

Codegen, Other (please specify), TurboModule - The New Native Module System

Output of npx @react-native-community/cli info

info Fetching system and libraries information...
System:
  OS: macOS 26.2
  CPU: (10) arm64 Apple M4
  Memory: 301.59 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.19.4
    path: /Users/admin/.nvm/versions/node/v20.19.4/bin/node
  Yarn: Not Found
  npm:
    version: 10.8.2
    path: /Users/admin/.nvm/versions/node/v20.19.4/bin/npm
  Watchman:
    version: 2025.06.30.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.16.2
    path: /Users/admin/.rvm/gems/ruby-3.1.0/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 25.4
      - iOS 26.4
      - macOS 26.4
      - tvOS 26.4
      - visionOS 26.4
      - watchOS 26.4
  Android SDK:
    API Levels:
      - "28"
      - "33"
      - "34"
      - "35"
      - "36"
    Build Tools:
      - 33.0.1
      - 34.0.0
      - 35.0.0
      - 36.0.0
    System Images:
      - android-33 | Google APIs ARM 64 v8a
      - android-34 | Google APIs ARM 64 v8a
      - android-34 | Google Play ARM 64 v8a
      - android-35 | Google Play ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: 2024.2 AI-242.23339.11.2421.12550806
  Xcode:
    version: 26.4/17E192
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.13
    path: /usr/bin/javac
  Ruby:
    version: 3.1.0
    path: /Users/admin/.rvm/rubies/ruby-3.1.0/bin/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 20.0.0
    wanted: 20.0.0
  react:
    installed: 19.2.0
    wanted: 19.2.0
  react-native:
    installed: 0.83.1
    wanted: 0.83.1
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true

Stacktrace or Logs

> Task :app:externalNativeBuildCleanDebug FAILED
Clean react_codegen_rnreanimated-arm64-v8a, react_codegen_safeareacontext-arm64-v8a, appmodules-arm64-v8a, react_codegen_rnworklets-arm64-v8a
C/C++: CMake Error at /Users/admin/Downloads/React-native-gradle-plugin-test/android/app/build/generated/autolinking/src/main/jni/Android-autolinking.cmake:9 (add_subdirectory):
C/C++:   add_subdirectory given source
C/C++:   "/Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/@d11/react-native-fast-image/android/build/generated/source/codegen/jni/"
C/C++:   which is not an existing directory.
C/C++: Call Stack (most recent call first):
C/C++:   /Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:94 (include)
C/C++:   CMakeLists.txt:31 (include)
C/C++: CMake Error at /Users/admin/Downloads/React-native-gradle-plugin-test/android/app/build/generated/autolinking/src/main/jni/Android-autolinking.cmake:10 (add_subdirectory):
C/C++:   add_subdirectory given source
C/C++:   "/Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/@react-native-clipboard/clipboard/android/build/generated/source/codegen/jni/"
C/C++:   which is not an existing directory.
C/C++: Call Stack (most recent call first):
C/C++:   /Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:94 (include)
C/C++:   CMakeLists.txt:31 (include)
C/C++: CMake Error at /Users/admin/Downloads/React-native-gradle-plugin-test/android/app/build/generated/autolinking/src/main/jni/Android-autolinking.cmake:11 (add_subdirectory):
C/C++:   add_subdirectory given source
C/C++:   "/Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/@react-native-community/netinfo/android/build/generated/source/codegen/jni/"
C/C++:   which is not an existing directory.
C/C++: Call Stack (most recent call first):
C/C++:   /Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:94 (include)
C/C++:   CMakeLists.txt:31 (include)
C/C++: CMake Error at /Users/admin/Downloads/React-native-gradle-plugin-test/android/app/build/generated/autolinking/src/main/jni/Android-autolinking.cmake:12 (add_subdirectory):
C/C++:   add_subdirectory given source
C/C++:   "/Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/react-native-config/android/build/generated/source/codegen/jni/"
C/C++:   which is not an existing directory.
C/C++: Call Stack (most recent call first):
C/C++:   /Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:94 (include)
C/C++:   CMakeLists.txt:31 (include)
C/C++: CMake Error at /Users/admin/Downloads/React-native-gradle-plugin-test/android/app/build/generated/autolinking/src/main/jni/Android-autolinking.cmake:13 (add_subdirectory):
C/C++:   add_subdirectory given source
C/C++:   "/Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/react-native-gesture-handler/android/build/generated/source/codegen/jni/"
C/C++:   which is not an existing directory.
C/C++: Call Stack (most recent call first):
C/C++:   /Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:94 (include)
C/C++:   CMakeLists.txt:31 (include)
C/C++: CMake Error at /Users/admin/Downloads/React-native-gradle-plugin-test/android/app/build/generated/autolinking/src/main/jni/Android-autolinking.cmake:14 (add_subdirectory):
C/C++:   add_subdirectory given source
C/C++:   "/Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/react-native-nitro-modules/android/build/generated/source/codegen/jni/"
C/C++:   which is not an existing directory.
C/C++: Call Stack (most recent call first):
C/C++:   /Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:94 (include)
C/C++:   CMakeLists.txt:31 (include)
C/C++: CMake Error at /Users/admin/Downloads/React-native-gradle-plugin-test/android/app/build/generated/autolinking/src/main/jni/Android-autolinking.cmake:15 (add_subdirectory):
C/C++:   add_subdirectory given source
C/C++:   "/Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/react-native-permissions/android/build/generated/source/codegen/jni/"
C/C++:   which is not an existing directory.
C/C++: Call Stack (most recent call first):
C/C++:   /Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:94 (include)
C/C++:   CMakeLists.txt:31 (include)
C/C++: CMake Error at /Users/admin/Downloads/React-native-gradle-plugin-test/android/app/build/generated/autolinking/src/main/jni/Android-autolinking.cmake:16 (add_subdirectory):
C/C++:   add_subdirectory given source
C/C++:   "/Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/react-native-reanimated/android/build/generated/source/codegen/jni/"
C/C++:   which is not an existing directory.
C/C++: Call Stack (most recent call first):
C/C++:   /Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:94 (include)
C/C++:   CMakeLists.txt:31 (include)
C/C++: CMake Error at /Users/admin/Downloads/React-native-gradle-plugin-test/android/app/build/generated/autolinking/src/main/jni/Android-autolinking.cmake:18 (add_subdirectory):
C/C++:   add_subdirectory given source
C/C++:   "/Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/react-native-share/android/build/generated/source/codegen/jni/"
C/C++:   which is not an existing directory.
C/C++: Call Stack (most recent call first):
C/C++:   /Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:94 (include)
C/C++:   CMakeLists.txt:31 (include)
C/C++: CMake Error at /Users/admin/Downloads/React-native-gradle-plugin-test/android/app/build/generated/autolinking/src/main/jni/Android-autolinking.cmake:19 (add_subdirectory):
C/C++:   add_subdirectory given source
C/C++:   "/Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/react-native-webview/android/build/generated/source/codegen/jni/"
C/C++:   which is not an existing directory.
C/C++: Call Stack (most recent call first):
C/C++:   /Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:94 (include)
C/C++:   CMakeLists.txt:31 (include)
C/C++: CMake Error at /Users/admin/Downloads/React-native-gradle-plugin-test/android/app/build/generated/autolinking/src/main/jni/Android-autolinking.cmake:20 (add_subdirectory):
C/C++:   add_subdirectory given source
C/C++:   "/Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/react-native-worklets/android/build/generated/source/codegen/jni/"
C/C++:   which is not an existing directory.
C/C++: Call Stack (most recent call first):
C/C++:   /Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:94 (include)
C/C++:   CMakeLists.txt:31 (include)
C/C++: CMake Error at /Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:97 (target_link_libraries):
C/C++:   Cannot specify link libraries for target "react_codegen_RNFastImageSpec"
C/C++:   which is not built by this project.
C/C++: Call Stack (most recent call first):
C/C++:   CMakeLists.txt:31 (include)
C/C++: ninja: error: rebuilding 'build.ninja': subcommand failed

[Incubating] Problems report is available at: file:///Users/admin/Downloads/React-native-gradle-plugin-test/android/build/reports/problems/problems-report.html

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:externalNativeBuildCleanDebug'.
> com.android.ide.common.process.ProcessException: ninja: Entering directory `/Users/admin/Downloads/React-native-gradle-plugin-test/android/app/.cxx/Debug/2l3a356k/arm64-v8a'
  [0/2] Re-checking globbed directories...
  [1/2] Re-running CMake...
  -- Configuring incomplete, errors occurred!
  See also "/Users/admin/Downloads/React-native-gradle-plugin-test/android/app/.cxx/Debug/2l3a356k/arm64-v8a/CMakeFiles/CMakeOutput.log".
  See also "/Users/admin/Downloads/React-native-gradle-plugin-test/android/app/.cxx/Debug/2l3a356k/arm64-v8a/CMakeFiles/CMakeError.log".
  FAILED: build.ninja 
  /Users/admin/Library/Android/sdk/cmake/3.22.1/bin/cmake --regenerate-during-build -S/Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/react-native/ReactAndroid/cmake-utils/default-app-setup -B/Users/admin/Downloads/React-native-gradle-plugin-test/android/app/.cxx/Debug/2l3a356k/arm64-v8a
  
  C++ build system [clean] failed while executing:
      /Users/admin/Library/Android/sdk/cmake/3.22.1/bin/ninja \
        -C \
        /Users/admin/Downloads/React-native-gradle-plugin-test/android/app/.cxx/Debug/2l3a356k/arm64-v8a \
        clean
    from /Users/admin/Downloads/React-native-gradle-plugin-test/android/app
  CMake Error at /Users/admin/Downloads/React-native-gradle-plugin-test/android/app/build/generated/autolinking/src/main/jni/Android-autolinking.cmake:9 (add_subdirectory):
    add_subdirectory given source
    "/Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/@d11/react-native-fast-image/android/build/generated/source/codegen/jni/"
    which is not an existing directory.
  Call Stack (most recent call first):
    /Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:94 (include)
    CMakeLists.txt:31 (include)
  
  
  CMake Error at /Users/admin/Downloads/React-native-gradle-plugin-test/android/app/build/generated/autolinking/src/main/jni/Android-autolinking.cmake:10 (add_subdirectory):
    add_subdirectory given source
    "/Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/@react-native-clipboard/clipboard/android/build/generated/source/codegen/jni/"
    which is not an existing directory.
  Call Stack (most recent call first):
    /Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:94 (include)
    CMakeLists.txt:31 (include)
  
  
  CMake Error at /Users/admin/Downloads/React-native-gradle-plugin-test/android/app/build/generated/autolinking/src/main/jni/Android-autolinking.cmake:11 (add_subdirectory):
    add_subdirectory given source
    "/Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/@react-native-community/netinfo/android/build/generated/source/codegen/jni/"
    which is not an existing directory.
  Call Stack (most recent call first):
    /Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:94 (include)
    CMakeLists.txt:31 (include)
  
  
  CMake Error at /Users/admin/Downloads/React-native-gradle-plugin-test/android/app/build/generated/autolinking/src/main/jni/Android-autolinking.cmake:12 (add_subdirectory):
    add_subdirectory given source
    "/Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/react-native-config/android/build/generated/source/codegen/jni/"
    which is not an existing directory.
  Call Stack (most recent call first):
    /Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:94 (include)
    CMakeLists.txt:31 (include)
  
  
  CMake Error at /Users/admin/Downloads/React-native-gradle-plugin-test/android/app/build/generated/autolinking/src/main/jni/Android-autolinking.cmake:13 (add_subdirectory):
    add_subdirectory given source
    "/Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/react-native-gesture-handler/android/build/generated/source/codegen/jni/"
    which is not an existing directory.
  Call Stack (most recent call first):
    /Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:94 (include)
    CMakeLists.txt:31 (include)
  
  
  CMake Error at /Users/admin/Downloads/React-native-gradle-plugin-test/android/app/build/generated/autolinking/src/main/jni/Android-autolinking.cmake:14 (add_subdirectory):
    add_subdirectory given source
    "/Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/react-native-nitro-modules/android/build/generated/source/codegen/jni/"
    which is not an existing directory.
  Call Stack (most recent call first):
    /Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:94 (include)
    CMakeLists.txt:31 (include)
  
  
  CMake Error at /Users/admin/Downloads/React-native-gradle-plugin-test/android/app/build/generated/autolinking/src/main/jni/Android-autolinking.cmake:15 (add_subdirectory):
    add_subdirectory given source
    "/Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/react-native-permissions/android/build/generated/source/codegen/jni/"
    which is not an existing directory.
  Call Stack (most recent call first):
    /Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:94 (include)
    CMakeLists.txt:31 (include)
  
  
  CMake Error at /Users/admin/Downloads/React-native-gradle-plugin-test/android/app/build/generated/autolinking/src/main/jni/Android-autolinking.cmake:16 (add_subdirectory):
    add_subdirectory given source
    "/Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/react-native-reanimated/android/build/generated/source/codegen/jni/"
    which is not an existing directory.
  Call Stack (most recent call first):
    /Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:94 (include)
    CMakeLists.txt:31 (include)
  
  
  CMake Error at /Users/admin/Downloads/React-native-gradle-plugin-test/android/app/build/generated/autolinking/src/main/jni/Android-autolinking.cmake:18 (add_subdirectory):
    add_subdirectory given source
    "/Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/react-native-share/android/build/generated/source/codegen/jni/"
    which is not an existing directory.
  Call Stack (most recent call first):
    /Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:94 (include)
    CMakeLists.txt:31 (include)
  
  
  CMake Error at /Users/admin/Downloads/React-native-gradle-plugin-test/android/app/build/generated/autolinking/src/main/jni/Android-autolinking.cmake:19 (add_subdirectory):
    add_subdirectory given source
    "/Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/react-native-webview/android/build/generated/source/codegen/jni/"
    which is not an existing directory.
  Call Stack (most recent call first):
    /Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:94 (include)
    CMakeLists.txt:31 (include)
  
  
  CMake Error at /Users/admin/Downloads/React-native-gradle-plugin-test/android/app/build/generated/autolinking/src/main/jni/Android-autolinking.cmake:20 (add_subdirectory):
    add_subdirectory given source
    "/Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/react-native-worklets/android/build/generated/source/codegen/jni/"
    which is not an existing directory.
  Call Stack (most recent call first):
    /Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:94 (include)
    CMakeLists.txt:31 (include)
  
  
  CMake Error at /Users/admin/Downloads/React-native-gradle-plugin-test/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:97 (target_link_libraries):
    Cannot specify link libraries for target "react_codegen_RNFastImageSpec"
    which is not built by this project.
  Call Stack (most recent call first):
    CMakeLists.txt:31 (include)
  
  
  ninja: error: rebuilding 'build.ninja': subcommand failed

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to generate a Build Scan (Powered by Develocity).
> Get more help at https://help.gradle.org.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 10.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to https://docs.gradle.org/9.0.0/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.

BUILD FAILED in 4s

MANDATORY Reproducer

https://github.com/Sagniknewme09/React-native-gradle-plugin-test

Public reproducer repo:
https://github.com/Sagniknewme09/React-native-gradle-plugin-test

Repro steps:

  1. npm install
  2. cd android
  3. ./gradlew clean

Observed:
Generated Android-autolinking.cmake contains unconditional add_subdirectory(...) entries for missing build/generated/source/codegen/jni directories, and clean fails.

Expected:
./gradlew clean should succeed even when those generated JNI directories do not exist yet.

Screenshots and Videos

No response

Activity

  1. added
    Type: New Architecture
    on Apr 5, 2026
  2. added
    Needs: Repro
    Platform: Android
    on Apr 5, 2026
  3. react-native-bot commented on Apr 5, 2026

    @react-native-bot
    Collaborator

    Warning

    Missing reproducer: We could not detect a reproducible example in your issue report. Reproducers are mandatory and we can accept only one of those as a valid reproducer:


    You can read more about about it on our website: How to report a bug.

  4. sagnik2001 commented on Apr 5, 2026

    @sagnik2001
    Author

    Added a public build reproducer and updated the report.

    Repo:
    https://github.com/Sagniknewme09/React-native-gradle-plugin-test

    This is a build/autolinking regression repro, not a Snack/RNTester case.
    Could you please review the issue again with the attached reproducer?

  5. added
    Needs: Attention
    and removed on Apr 5, 2026
  6. sagnik2001 commented on Apr 5, 2026

    @sagnik2001
    Author

    I was able to work around this locally by patching
    GenerateAutolinkingNewArchitecturesFileTask.kt.

    What I changed:

    • wrap each generated add_subdirectory(...) entry in if(EXISTS "...")
    • only append a library to AUTOLINKED_LIBRARIES if that native directory was actually added
    • initialize AUTOLINKED_LIBRARIES as empty first, instead of unconditionally listing every generated target

    Why this fixes it:
    Android-autolinking.cmake currently assumes every autolinked JNI/codegen directory exists.
    During ./gradlew clean, many of those directories are absent, so CMake fails immediately on
    add_subdirectory(...), and then target_link_libraries(...) also fails because those targets
    were never created.

    With the guard in place:

    • existing JNI/codegen dirs are included normally
    • missing dirs are skipped safely
    • ./gradlew clean succeeds

    I verified this locally:

    • unpatched: ./gradlew clean fails with missing build/generated/source/codegen/jni/ directories
    • patched: ./gradlew clean succeeds

    If this direction looks correct, I can open a PR with the change.

  7. elijahsanders152-stack commented on Apr 5, 2026

    @elijahsanders152-stack
  8. kevinbluepixel commented on Apr 27, 2026

    @kevinbluepixel

    Confirming this also reproduces on RN 0.78.0 with New Architecture enabled, so the bug pre-dates 0.83. Two data points that may strengthen the upstream fix:

    Prefab dependency angle (not only codegen)

    configureCMake* is missing dependencies on two sets of tasks from consumed libraries:

    1. Codegen tasks (generateCodegenSchemaFromJavaScript → generateCodegenArtifactsFromSchema → preBuild) that produce <lib>/android/build/generated/source/codegen/jni/ — what this issue currently covers.
    2. Prefab packaging tasks (prefab<Variant>Package) that produce <lib>/android/build/intermediates/prefab_package/<variant>/prefab for libs that publish prefab (e.g. @shopify/react-native-skia, react-native-reanimated).

    The two failure modes look different. Missing codegen → add_subdirectory given source ... is not an existing directory. Missing prefab → <package_path>: directory ... is not readable. The CMake if(EXISTS ...) workaround proposed above handles only the first case; we hit the second on a clean build right after the first was resolved.

    Alternative workaround — wire the missing dependencies in Gradle

    Instead of guarding the generated CMake (which would silently skip libs whose codegen tasks never ran), we restored the missing Gradle dependencies in `app/build.gradle`:

    ```groovy
    afterEvaluate {
    def cmakeTasks = tasks.matching { it.name.startsWith("configureCMake") || it.name.startsWith("buildCMake") }
    rootProject.subprojects.each { sub ->
    if (sub == project) return
    sub.tasks.matching { it.name == "preBuild" }.all { preBuild ->
    cmakeTasks.configureEach { it.dependsOn(preBuild) }
    }
    sub.tasks.matching { it.name.startsWith("prefab") && it.name.endsWith("Package") }.all { prefabTask ->
    cmakeTasks.configureEach { it.dependsOn(prefabTask) }
    }
    }
    }
    ```

    This forces the codegen and prefab tasks to actually run before CMake configure. A clean `bundleRelease` then succeeds without any CMake-side guards.

    Both approaches probably belong upstream: the Gradle wiring as the proper fix (so consumers' codegen actually runs), the CMake `if(EXISTS ...)` guard as defense in depth.

    Affected libraries in our project (RN 0.78.0, New Arch)

    Codegen-only: `@d11/react-native-fast-image`, `@react-native-async-storage/async-storage`, `@react-native-community/blur`, `@react-native-community/datetimepicker`, `@sentry/react-native`, `react-native-vector-icons`, `react-native-haptic-feedback`, `react-native-keychain`, `react-native-localize`, `react-native-permissions`, `react-native-gesture-handler`.

    Prefab: `@shopify/react-native-skia`, `react-native-reanimated`.

  9. zerobertelprivat commented on May 11, 2026

    @zerobertelprivat

    Had this problem also in RN 83.4, doing

    rm -rf android/app/.cxx
    rm -rf android/app/build
    rm -rf android/build
    rm -rf android/.gradle

    before the clean fixed it for me

  10. react-native-bot commented on Nov 8, 2026

    @react-native-bot
    Collaborator

    This issue is stale because it has been open for 180 days with no activity. It will be closed in 7 days unless you comment on it or remove the "Stale" label.

  11. added
    Stale
    and removed
    Stale
    on Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    API: LinkingNeeds: AttentionNeeds: ReproPlatform: AndroidType: New Architecture

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions