From 7c4dc5d1851900569e994cbb35b70d162c1471ab Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Tue, 13 Feb 2024 14:29:45 -0800 Subject: [PATCH] Always use aapt2 --no-static-lib-packages --no-static-lib-packages was removed when compiling libraries with use_resource_processor: true enabled, but that caused problems resolving attributes of styleables. androidx.preference declares the "icon" attribute inside a , but doesn't give it a format. aapt2 refuses to create a new attribute for this case (b/131100106), but without --no-static-lib-packages aapt2 can resolve the attribute from the one defined in androidx.appcompat. Bug: 294256649 Test: builds Change-Id: I13661be83ba6501b0c2b1af8e632f260f405a370 --- java/aar.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/java/aar.go b/java/aar.go index f61fc8374..7dcf1d155 100644 --- a/java/aar.go +++ b/java/aar.go @@ -414,17 +414,11 @@ func (a *aapt) buildActions(ctx android.ModuleContext, opts aaptBuildActionOptio linkFlags = append(linkFlags, "--static-lib") } + linkFlags = append(linkFlags, "--no-static-lib-packages") if a.isLibrary && a.useResourceProcessorBusyBox(ctx) { - // When building an android_library using ResourceProcessorBusyBox the resources are merged into - // package-res.apk with --merge-only, but --no-static-lib-packages is not used so that R.txt only - // contains resources from this library. + // When building an android_library using ResourceProcessorBusyBox pass --merge-only to skip resource + // references validation until the final app link step when all static libraries are present. linkFlags = append(linkFlags, "--merge-only") - } else { - // When building and app or when building an android_library without ResourceProcessorBusyBox - // --no-static-lib-packages is used to put all the resources into the app. If ResourceProcessorBusyBox - // is used then the app's R.txt will be post-processed along with the R.txt files from dependencies to - // sort resources into the right packages in R.class. - linkFlags = append(linkFlags, "--no-static-lib-packages") } packageRes := android.PathForModuleOut(ctx, "package-res.apk") @@ -1177,6 +1171,7 @@ func (a *AARImport) GenerateAndroidBuildActions(ctx android.ModuleContext) { "--static-lib", "--merge-only", "--auto-add-overlay", + "--no-static-lib-packages", } linkFlags = append(linkFlags, "--manifest "+a.manifest.String())