Repository navigation
fix(bgp): merge res/values of embedded libraries instead of overwriting - #513
Open
KisaneNeko wants to merge 2 commits into
Open
KisaneNeko wants to merge 2 commits into
KisaneNeko wants to merge 2 commits into
Conversation
callstack#413 made each library's res/values/values.xml replace the previous one, since every exploded AAR stores its values under that path. Merge them with sdk-common's ResourceMerger instead, like AGP's fused library plugin does: one resource set per library, with the module's own res and resValues on top, so the module wins, then the first library. callstack#125 came from keeping a resource twice in one dir, so only the winners are written, and an attr is defined once. Refs callstack#490
KisaneNeko
force-pushed
the
fix/bgp-aar-merge-res-values
branch
from
October 23, 2026 11:07
fa112b7 to
7648ca5
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.
Refs #490
Problem
Every exploded AAR stores its values in
res/values/values.xml. Since #413,CopyExplodedResTaskcopies each library'sres/over the previous one, so only the last library's values survive. A host app withreact-native-bootsplashfails at resource linking (attr/bootSplashBackground not found). Onmainthe Expo 58 demo AAR already loses resources ofexpo-system-ui,expo-status-bar,expo-splash-screenand@callstack/react-native-brownfield.Change
CopyExplodedResTask: merge with sdk-common'sResourceMerger, the way AGP's fused library plugin does: oneResourceSetper library, lowest priority first, and one per module static res dir on top. That gives the precedence Android uses in an app (docs): the module's ownresandresValues first, then the first library. Qualifier normalization, styleable merging and file vs value collisions come from AGP.LibraryResWriter: writes only the library winners the module doesn't define, so each resource ends up once in the generated dir and the "Duplicate resources" failure from Build Failure: Duplicate Resources Error During AAR Packaging with React Native Libraries #125 doesn't come back. An attr with aformatdeclared inside styleables is written once as a top-level<attr>, with a warning when two libraries define it differently.drawable/x.png,drawable/x.xmland<drawable name="x">count as the same resource. For such files the first library now wins; before, the last one did, or both were kept and the build failed.libraryOrderinput, so the build cache key changes when the library order does.variant.resValuesis read only when the feature is on, since AGP 9 has it off by default and warns on every read.sdk-commonandlayoutlib-apiascompileOnly, at the same version ascommon. AGP brings both at runtime; the APIs used are unchanged from 31.12 to 32.3.1.CopyExplodedResTaskTest: 16 cases, each reloading the output as oneResourceSetwith validation on, as AGP does.AgpCompatibilityMatrixTestnow fails if the resValues warning shows up.2.0.0-alpha13(yarn brownfield:plugin:version:sync). Meant to merge after fix(bgp): package local jars of embedded libraries into the AAR #512 (alpha12).Verified with
react-native-bootsplash7.1.0 in the RN demo app: onmainthe consumerAndroidAppfails atprocessVanillaReleaseResourceswith the error above and the AAR misses 28 of its 44 entries; with the change none are missing and the consumer builds. Also with a local RN library that has an attr invaluesand a style using it invalues-v31, on Expo 58 and Expo 57. Detox E2E passes for vanilla, Expo 58 and Expo 57, and a module's ownapp_namenow wins over the one from@callstack/react-native-brownfield(onmainthe library's copy can replace it).Not covered
Resources from other plugins' generated res dirs (for example google-services) don't count as the module's own: reading them would include this task's own output.