import re


def extract_target_sdk_version_apk(badging):
  """Extract targetSdkVersion tags from the manifest of an APK."""

  pattern = re.compile("^targetSdkVersion?:'(.*)'$", re.MULTILINE)

  for match in re.finditer(pattern, badging):
    return match.group(1)

  raise RuntimeError('cannot find targetSdkVersion in the manifest')