Do not remove RRO resources
Resource configs should not be deduped when building RROs since it
would be impossible to override some resource configs with the same
value as the default config. Also, aapt2 removes resources that do not
have default configurations. If an overlay attempts to overlay a
non-default configuration without overlaying the default, the resource
will be removed and the value will not be overlaid at all.
Bug: 146227008
Fixes: 119811120
Test: app_test.go
Change-Id: I834a58b18d1e74a0f6b3de3d0523009788787e42
diff --git a/java/app.go b/java/app.go
index d253a12..c59047d 100755
--- a/java/app.go
+++ b/java/app.go
@@ -1257,7 +1257,8 @@
func (r *RuntimeResourceOverlay) GenerateAndroidBuildActions(ctx android.ModuleContext) {
// Compile and link resources
r.aapt.hasNoCode = true
- r.aapt.buildActions(ctx, r)
+ // Do not remove resources without default values nor dedupe resource configurations with the same value
+ r.aapt.buildActions(ctx, r, "--no-resource-deduping", "--no-resource-removal")
// Sign the built package
_, certificates := collectAppDeps(ctx, false)
diff --git a/java/app_test.go b/java/app_test.go
index ce5c893..2682682 100644
--- a/java/app_test.go
+++ b/java/app_test.go
@@ -2214,6 +2214,7 @@
name: "foo",
certificate: "platform",
product_specific: true,
+ aaptflags: ["--keep-raw-values"],
}
runtime_resource_overlay {
@@ -2226,6 +2227,14 @@
m := ctx.ModuleForTests("foo", "android_common")
+ // Check AAPT2 link flags.
+ aapt2Flags := m.Output("package-res.apk").Args["flags"]
+ expectedFlags := []string{"--keep-raw-values", "--no-resource-deduping", "--no-resource-removal"}
+ absentFlags := android.RemoveListFromList(expectedFlags, strings.Split(aapt2Flags, " "))
+ if len(absentFlags) > 0 {
+ t.Errorf("expected values, %q are missing in aapt2 link flags, %q", absentFlags, aapt2Flags)
+ }
+
// Check cert signing flag.
signedApk := m.Output("signed/foo.apk")
signingFlag := signedApk.Args["certificates"]