Repository navigation
Conversation
Signed-off-by: izbari <73957984+izbari@users.noreply.github.com>
izbari
force-pushed
the
fix/relocated-codegen-cmake
branch
from
December 4, 2026 13:22
2e973cd to
215b9dc
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes react-native-community/cli#2898. Moving an Android library's Gradle build directory makes Codegen and CMake disagree about where the generated JNI sources live. In the reporter's app, CMake skips
react_codegen_rnworkletsand the release build fails compilingautolinking.cppwith'rnworklets.h' file not found.The Gradle plugin can resolve the generated JNI path from the included library project's
layout.buildDirectory. Pass that path to the autolinking task as a lazy task input when the CLI reports the conventional generated CMake path. Libraries with a separate CMake project and pure C++ dependencies continue through their existing paths.Changelog
[ANDROID] [FIXED] - Fix native autolinking when an Android library generates Codegen sources in a relocated Gradle build directory.
Test Plan
packages/gradle-plugin, ran./gradlew :react-native-gradle-plugin:test --tests '*autolinking_usesLibraryBuildDirectoryForGeneratedCmake'. Before the fix the assertion showedworklets/build/generated/source/codegen/jni/in the generated CMake. The test expectsbuild/modules/worklets/generated/source/codegen/jni/after changing the library's build directory, even when the task has already been realized. The same test passed with the fix. Ran./gradlew test --max-workers=2for the Gradle plugin build. All 295 tests passed../gradlew assembleRelease -PreactNativeArchitectures=arm64-v8a --max-workers=2 --console=plaininandroid/. The release APK built successfully. The generated CMake adds the worklets target fromandroid/build/modules/react-native-worklets/generated/source/codegen/jni/.Codex assisted with the implementation and ran the verification above.