Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6871779d authored by Kelvin Zhang's avatar Kelvin Zhang
Browse files

Fix signing failure for split APKs

Test: th
Bug: 353837347
Change-Id: Ifed9746c1e1d053a97860de3bab4380d6e207412
parent 24212471
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -2434,12 +2434,23 @@ def GetMinSdkVersion(apk_name):
        "Failed to obtain minSdkVersion for {}: aapt2 return code {}:\n{}\n{}".format(
            apk_name, proc.returncode, stdoutdata, stderrdata))

  is_split_apk = False
  for line in stdoutdata.split("\n"):
    # See b/353837347 , split APKs do not have sdk version defined,
    # so we default to 21 as split APKs are only supported since SDK
    # 21.
    if (re.search(r"split=[\"'].*[\"']", line)):
      is_split_apk = True
    # Due to ag/24161708, looking for lines such as minSdkVersion:'23',minSdkVersion:'M'
    # or sdkVersion:'23', sdkVersion:'M'.
    m = re.match(r'(?:minSdkVersion|sdkVersion):\'([^\']*)\'', line)
    if m:
      return m.group(1)
  if is_split_apk:
    logger.info("%s is a split APK, it does not have minimum SDK version"
                " defined. Defaulting to 21 because split APK isn't supported"
                " before that.", apk_name)
    return 21
  raise ExternalError("No minSdkVersion returned by aapt2 for apk: {}".format(apk_name))