diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py index 418d8daa85..ec49b0d36f 100644 --- a/tools/releasetools/common.py +++ b/tools/releasetools/common.py @@ -2309,12 +2309,22 @@ def GetMinSdkVersionInt(apk_name, codename_to_api_level_map): try: return int(version) except ValueError: - # Not a decimal number. Codename? - if version in codename_to_api_level_map: - return codename_to_api_level_map[version] + # Not a decimal number. + # + # It could be either a straight codename, e.g. + # UpsideDownCake + # + # Or a codename with API fingerprint SHA, e.g. + # UpsideDownCake.e7d3947f14eb9dc4fec25ff6c5f8563e + # + # Extract the codename and try and map it to a version number. + split = version.split(".") + codename = split[0] + if codename in codename_to_api_level_map: + return codename_to_api_level_map[codename] raise ExternalError( - "Unknown minSdkVersion: '{}'. Known codenames: {}".format( - version, codename_to_api_level_map)) + "Unknown codename: '{}' from minSdkVersion: '{}'. Known codenames: {}".format( + codename, version, codename_to_api_level_map)) def SignFile(input_name, output_name, key, password, min_api_level=None,