From 402d5e091996abe6e69b5055150ab5438fc664ef Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Wed, 25 Apr 2018 14:54:06 -0700 Subject: [PATCH] Don't use AppsDefaultVersionName for framework-res.apk Some builds set AppsDefaultVersionName() to include the build number ("P-123456"). aapt2 copies the version name of framework-res into app manifests as compileSdkVersionCodename, which confuses things if it contains the build number. Use the DefaultAppTargetSdk ("P") instead. Bug: 78324052 Test: m TARGET_BUILD_WITH_APPS_VERSION_NAME=true Dialer aapt dump badging $OUT/system/priv-app/Dialer/Dialer.apk | grep compile shows compileSdkVersionCodename=P Change-Id: If67f40aae1066d4ff3bf97da1b2de2e1e250ad9c --- java/aar.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/java/aar.go b/java/aar.go index 13c536940..16d82af45 100644 --- a/java/aar.go +++ b/java/aar.go @@ -143,7 +143,16 @@ func (a *aapt) aapt2Flags(ctx android.ModuleContext, sdkVersion string) (flags [ } if !hasVersionName { - versionName := proptools.NinjaEscape([]string{ctx.Config().AppsDefaultVersionName()})[0] + var versionName string + if ctx.ModuleName() == "framework-res" { + // Some builds set AppsDefaultVersionName() to include the build number ("O-123456"). aapt2 copies the + // version name of framework-res into app manifests as compileSdkVersionCodename, which confuses things + // if it contains the build number. Use the DefaultAppTargetSdk instead. + versionName = ctx.Config().DefaultAppTargetSdk() + } else { + versionName = ctx.Config().AppsDefaultVersionName() + } + versionName = proptools.NinjaEscape([]string{versionName})[0] linkFlags = append(linkFlags, "--version-name ", versionName) }