From f59ad14c1f7cb07a4669741f8b0bb1e938398eca Mon Sep 17 00:00:00 2001 From: Alex Klyubin Date: Wed, 11 May 2016 12:11:11 -0700 Subject: [PATCH] Fix handling of version codes in minSdkVersion when signing. The APK signing tool, build/tools/signapk, needs to know the API Level of the oldest platform supported by the APK. The APK's minSdkVersion may reference that using a number (API Level) or a version code. To handle the version code case, the existing logic was to see if it matches $PLATFORM_VERSION_CODENAME and then substitute it with $PLATFORM_SDK_VERSION. However, some platforms support multiple version codes. To handle this scenario, this commit changes the logic for computing the min API Level for signing purposes to treat any non-numeric minSdkVersion as $PLATFORM_SDK_VERSION. Bug: 28715556 Change-Id: I292c96e8928b7e2f8d9716ef2be33a23a87764c4 --- core/definitions.mk | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/definitions.mk b/core/definitions.mk index 5c01bc2cbd..5d24b671f1 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -2446,10 +2446,14 @@ endef # decimal number) instead. If the APK does not specify a minSdkVersion, returns # 0 to match how the Android platform interprets this situation at runtime. # +# This currently substitutes any version which contains characters other than +# digits with the current platform's API Level number. This is because I +# couldn't figure out an easy way to perform the substitution only for the +# version codes listed in PLATFORM_VERSION_ALL_CODENAMES. define get-package-min-sdk-version-int $$(($(AAPT) dump badging $(1) 2>&1 | grep '^sdkVersion' || echo "sdkVersion:'0'") \ | cut -d"'" -f2 | \ - sed -e s/^$(PLATFORM_VERSION_CODENAME)$$/$(PLATFORM_SDK_VERSION)/) + sed -e s/^.*[^0-9].*$$/$(PLATFORM_SDK_VERSION)/) endef # Sign a package using the specified key/cert.