fix(gradle-plugin): guard missing autolinked JNI dirs#56886
Closed
Phecda wants to merge 2 commits into
Closed
Conversation
Scope this change to Android New Architecture CMake autolinking. Generate Android-autolinking.cmake so missing codegen JNI directories are skipped instead of failing clean/native model configuration, and only append libraries after their directories are added.
cortinico
reviewed
May 19, 2026
| if(EXISTS "$nativeFolderPath") | ||
| add_subdirectory("$nativeFolderPath" ${libraryName}_autolinked_build) | ||
| list(APPEND AUTOLINKED_LIBRARIES $CODEGEN_LIB_PREFIX${libraryName}) | ||
| endif() |
Contributor
There was a problem hiding this comment.
This is great however I'm a bit concerned of this potentially exposing us to silent failures. Perhaps we should emit a message if the folder is not existing?
Contributor
Author
There was a problem hiding this comment.
OK, I added warning messages when an autolinked directory is skipped. Thanks for the review!
|
@cortinico has imported this pull request. If you are a Meta employee, you can view this in D105826478. |
Collaborator
|
This pull request was successfully merged by @Phecda in 948835d When will my fix make it into a release? | How to file a pick request? |
|
@cortinico merged this pull request in 948835d. |
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:
Related to #56334.
GenerateAutolinkingNewArchitecturesFileTaskcurrently emits unconditionaladd_subdirectory(...)calls for autolinked New Architecture JNI/codegen directories.During
clean, Android Studio native model configuration, or other native cleanup/configuration flows, some dependency codegen directories may not exist yet. CMake then fails before clean/configuration can complete:This changes the generated
Android-autolinking.cmaketo:AUTOLINKED_LIBRARIESas an empty list;add_subdirectory(...)when the native directory exists;That keeps existing generated JNI directories linked as before while allowing native clean/model configuration to skip directories that have not been generated yet.
Changelog:
[ANDROID] [FIXED] - Guard missing autolinked JNI directories in generated CMake during native clean/model configuration.
Test Plan:
Result: