From bb77d8e948b147ff5d1c7c742e4fc7b7254f8697 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Thu, 15 Feb 2024 14:43:47 -0800 Subject: [PATCH] Use R.txt files from aar files directly Use the R.txt files from aar imports directly instead of recreating one using aapt2 from the embedded resources. Fixes an issue with com.google.android.material where the jar was referencing com.google.android.material.R.attr.theme, aapt2 was not producing "int attr theme 0x0" in R.txt, but the aar's R.txt had it. Bug: 294256649 Test: builds Change-Id: Ibe1e5535a75eed59f3b8dbbc12eff9c07af51d37 --- java/aar.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/java/aar.go b/java/aar.go index f61fc8374a..79c552d51a 100644 --- a/java/aar.go +++ b/java/aar.go @@ -1136,7 +1136,7 @@ func (a *AARImport) GenerateAndroidBuildActions(ctx android.ModuleContext) { extractedAARDir := android.PathForModuleOut(ctx, "aar") a.classpathFile = extractedAARDir.Join(ctx, "classes-combined.jar") a.manifest = extractedAARDir.Join(ctx, "AndroidManifest.xml") - aarRTxt := extractedAARDir.Join(ctx, "R.txt") + a.rTxt = extractedAARDir.Join(ctx, "R.txt") a.assetsPackage = android.PathForModuleOut(ctx, "assets.zip") a.proguardFlags = extractedAARDir.Join(ctx, "proguard.txt") android.SetProvider(ctx, ProguardSpecInfoProvider, ProguardSpecInfo{ @@ -1150,7 +1150,7 @@ func (a *AARImport) GenerateAndroidBuildActions(ctx android.ModuleContext) { ctx.Build(pctx, android.BuildParams{ Rule: unzipAAR, Input: a.aarPath, - Outputs: android.WritablePaths{a.classpathFile, a.proguardFlags, a.manifest, a.assetsPackage, aarRTxt}, + Outputs: android.WritablePaths{a.classpathFile, a.proguardFlags, a.manifest, a.assetsPackage, a.rTxt}, Description: "unzip AAR", Args: map[string]string{ "outDir": extractedAARDir.String(), @@ -1168,7 +1168,7 @@ func (a *AARImport) GenerateAndroidBuildActions(ctx android.ModuleContext) { a.exportPackage = android.PathForModuleOut(ctx, "package-res.apk") proguardOptionsFile := android.PathForModuleGen(ctx, "proguard.options") - a.rTxt = android.PathForModuleOut(ctx, "R.txt") + aaptRTxt := android.PathForModuleOut(ctx, "R.txt") a.extraAaptPackagesFile = android.PathForModuleOut(ctx, "extra_packages") var linkDeps android.Paths @@ -1204,7 +1204,7 @@ func (a *AARImport) GenerateAndroidBuildActions(ctx android.ModuleContext) { } transitiveAssets := android.ReverseSliceInPlace(staticDeps.assets()) - aapt2Link(ctx, a.exportPackage, nil, proguardOptionsFile, a.rTxt, + aapt2Link(ctx, a.exportPackage, nil, proguardOptionsFile, aaptRTxt, linkFlags, linkDeps, nil, overlayRes, transitiveAssets, nil, nil) a.rJar = android.PathForModuleOut(ctx, "busybox/R.jar")