fix: duplicate .so resources on cold builds#414
Open
artus9033 wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a first-run AAR publish failure caused by merge<Variant>JniLibFolders seeing duplicate .so resources when useStrippedSoFiles stages native libs into libs<Variant> on cold builds.
Changes:
- Wire
libs<Variant>intosourceSet.jniLibsvia aFileCollectionthat isbuiltBy(copy<Variant>LibSources)instead of a staticsrcDirs(...)entry. - Remove the redundant
dependsOn(copy<Variant>LibSources)frommerge<Variant>JniLibFoldersconfiguration so the directory isn’t effectively introduced twice.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/processors/JNILibsProcessor.kt | Removes explicit merge-task dependency on the copy task; ordering is now provided via builtBy wiring. |
| gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/plugin/RNSourceSets.kt | Registers libs<Variant> as a JNI libs source through a builtBy(copy<Variant>LibSources) file collection when useStrippedSoFiles is enabled. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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 a first-run failure when publishing the brownfield AAR (
publishToMavenLocal/brownfield publish:android) withResource and asset merger: Duplicate resourceserrors for .so files inlibsDebug/libsRelease.Problem
With useStrippedSoFiles enabled (default), native libraries are staged into
libs<Variant>(e.g.libsDebug) bycopy<Variant>LibSources, and that folder is also registered as a JNI source directory formerge<Variant>JniLibFolders.On a cold build, Gradle saw the same directory twice in the merge inputs:
jniLibs.srcDirs("libsDebug")entrymergeJniLibFolders.dependsOn(copyDebugLibSources), which writes to the same pathThat produced duplicate-resource errors for every .so file. A second publish often succeeded because the copy task was
UP-TO-DATEand the input wiring differed.Fix
RNSourceSets.kt: register JNI libs viaproject.files(libsDir).builtBy(copy<Variant>LibSources)instead of a staticsrcDirs(...), matching how Expo updates assets are wired,JNILibsProcessor.kt: remove the redundantdependsOn(copyTask)onmergeJniLibFolders; task ordering is now handled bybuiltBy.This ensures
libs<Variant>is included once in the JNI merge inputs while preserving the existing copy +copyStrippedSoLibsbehavior.Test plan
CI green.