diff --git a/src/Xamarin.Android.Build.Tasks/Utilities/ManifestDocument.cs b/src/Xamarin.Android.Build.Tasks/Utilities/ManifestDocument.cs index 0c5baa2651c..b05e022ebf5 100644 --- a/src/Xamarin.Android.Build.Tasks/Utilities/ManifestDocument.cs +++ b/src/Xamarin.Android.Build.Tasks/Utilities/ManifestDocument.cs @@ -70,19 +70,17 @@ public string VersionCode { doc.Root.SetAttributeValue (androidNs + "versionCode", value); } } - public string MinimumSdk { - get { - var uses = doc.Root.Element ("uses-sdk"); - if (uses?.Attribute (androidNs + "minSdkVersion") == null) { - int minSdkVersion; - if (!int.TryParse (SdkVersionName, out minSdkVersion)) - minSdkVersion = 11; - return Math.Min (minSdkVersion, 11).ToString (); - } else { - return uses.Attribute (androidNs + "minSdkVersion").Value; - } + public string GetMinimumSdk () { + var minAttr = doc.Root.Element ("uses-sdk")?.Attribute (androidNs + "minSdkVersion"); + if (minAttr == null) { + int minSdkVersion; + if (!int.TryParse (SdkVersionName, out minSdkVersion)) + minSdkVersion = 11; + return Math.Min (minSdkVersion, 11).ToString (); } + return minAttr.Value; } + TaskLoggingHelper log; public ManifestDocument (string templateFilename, TaskLoggingHelper log) : base () @@ -877,7 +875,7 @@ public void CalculateVersionCode (string currentAbi, string versionCodePattern, if (!kvp.ContainsKey ("versionCode")) kvp.Add ("versionCode", int.Parse (VersionCode)); if (!kvp.ContainsKey ("minSDK")) { - kvp.Add ("minSDK", int.Parse (MinimumSdk)); + kvp.Add ("minSDK", int.Parse (GetMinimumSdk ())); } var versionCode = String.Empty; foreach (Match match in regex.Matches (versionCodePattern)) {