Skip to content

Commit cd7da91

Browse files
committed
[Xamarin.Android.Build.Utilities] Add AndroidVersions
Commit 8e7d37b is a sign of duplication: in order to use a `Mono.Android.dll` binding assembly, not only do we need to *build* the binding assembly, but we *also* need to update `Xamarin.Android.Build.Utilities.dll` to "know" about the new binding version (to map API level to `$(TargetFrameworkVersion)`). Even "better" (worse), if the new API level is a *preview*, there is no *consistent* API level. For example, with API-O, `android.jar` isn't at `$(AndroidSdkDirectory)\platforms\android-@API_LEVEL@\android.jar`, where `@API_LEVEL@` is 26 (because various codepaths require that the "api level" be an integer). Instead, it's installed at `$(AndroidSdkDirectory)\platforms\android-O\android.jar`, where `O` is the "id" of the preview API level. This "id" is "leaky", in turn requiring that `Xamarin.Android.Build.Tasks.dll` *also* be updated to deal with the mappings. Even "better" (worse), if we *forget* to cross all our our 't's and dot all of our 'i's, we'll have a binding assembly which can't be used. (Which is why we needed commit 8e7d37b; without it, the API-O binding can't be used!) This is all obviously madness. ;-) Clean this mess up: 1. Update `src/Mono.Android` to create a new `AndroidApiInfo.xml` file within the `$(TargetFrameworkVersion)` directory. This will contain all the information needed to map Android API levels to Ids and Android OS versions and `$(TargetFrameworkVersion)` values. ``` <AndroidApiInfo> <Id>10</Id> <Level>10</Level> <Name>Gingerbread</Name> <Version>v2.3</Version> </AndroidApiInfo> ``` 2. Add a new `Xamarin.Android.Build.Utilities.AndroidVersions` type which looks for and parses these new `AndroidApiInfo.xml` files. 3. Fixup all the other places using `AndroidVersion.KnownVersions` and related members to instead use `AndroidVersions`. 4. Remove all the old APIs which rely on hardcoded data. The advantage to all this is that we can support new API level bindings by just building a new `Mono.Android.dll` and placing an `AndroidApiInfo.xml` into the appropriate location (next to `Mono.Android.dll`). No further code changes would be required. Related: The build system still has a nasy habit of using system-wide directories to resolve files we'd really rather it not, e.g. in [xamarin-android/master build #503][m503]: [m503]: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android/503/consoleText Building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj" ("/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/Xamarin/Android/Xamarin.Android.Common.targets"); "_SetLatestTargetFrameworkVersion" depends on it. Target _GetReferenceAssemblyPaths: Task "GetReferenceAssemblyPaths" Using task GetReferenceAssemblyPaths from Microsoft.Build.Tasks.GetReferenceAssemblyPaths, Microsoft.Build.Tasks.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a Looking for framework 'MonoAndroid,Version=v1.0' in root path '/Library/Frameworks/Mono.framework/External/xbuild-frameworks' Found framework definition list '/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/RedistList/FrameworkList.xml' for framework 'MonoAndroid,Version=v1.0' Done executing task "GetReferenceAssemblyPaths" Done building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj". Done building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj" ("/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/Xamarin/Android/Xamarin.Android.Common.targets"); "_SetLatestTargetFrameworkVersion" depends on it. Target _SetLatestTargetFrameworkVersion: Task "ResolveSdks" ReferenceAssemblyPaths: /Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/ Note the use of the path `/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0`. This *was* "fine" -- if undesirable -- but with the introduction of `AndroidVersions` and `AndroidApiInfo.xml` files within the frameworks directory, everything falls apart, becuase the system install *does not have* the `AndroidApiInfo.xml` files, so *NO API LEVELS ARE FOUND*. Oops. The only way to fix this is to use `$XBUILD_FRAMEWORK_FOLDERS_PATH`, and the sanest way to do *that* is to use `tools/scripts/xabuild` for the primary build. Unfortunately, using `xabuild` for the primary build breaks the `msbuild`-based build, as it can't resolve the `.NETFramework,Version=v4.6.1` framework. Context: #599 (comment) Split the difference here by introducing `$(_SLN_BUILD)`: use `xabuild` when building with `xbuild`, and continue using `msbuild` when building with `msbuild`.
1 parent 759fd47 commit cd7da91

19 files changed

+418
-516
lines changed

Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,15 @@ export MONO_OPTIONS
2121
endif
2222

2323
include build-tools/scripts/msbuild.mk
24+
25+
ifeq ($(USE_MSBUILD),1)
26+
_SLN_BUILD = $(MSBUILD)
27+
else # $(MSBUILD) != 1
28+
_SLN_BUILD = MSBUILD="$(MSBUILD)" tools/scripts/xabuild
29+
endif # $(USE_MSBUILD) == 1
30+
2431
all::
25-
$(MSBUILD) $(MSBUILD_FLAGS) $(SOLUTION)
32+
$(_SLN_BUILD) $(MSBUILD_FLAGS) $(SOLUTION)
2633

2734
all-tests::
2835
MSBUILD="$(MSBUILD)" tools/scripts/xabuild $(MSBUILD_FLAGS) Xamarin.Android-Tests.sln
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<AndroidApiInfo Include="v1.6">
5+
<Name>Donut</Name>
6+
<Level>4</Level>
7+
<Id>4</Id>
8+
<Stable>True</Stable>
9+
</AndroidApiInfo>
10+
<AndroidApiInfo Include="v2.0">
11+
<Name>Eclair</Name>
12+
<Level>5</Level>
13+
<Id>5</Id>
14+
<Stable>True</Stable>
15+
</AndroidApiInfo>
16+
<AndroidApiInfo Include="v2.0.1">
17+
<Name>Eclair</Name>
18+
<Level>6</Level>
19+
<Id>6</Id>
20+
<Stable>True</Stable>
21+
</AndroidApiInfo>
22+
<AndroidApiInfo Include="v2.1">
23+
<Name>Eclair</Name>
24+
<Level>7</Level>
25+
<Id>7</Id>
26+
<Stable>True</Stable>
27+
</AndroidApiInfo>
28+
<AndroidApiInfo Include="v2.2">
29+
<Name>Froyo</Name>
30+
<Level>8</Level>
31+
<Id>8</Id>
32+
<Stable>True</Stable>
33+
</AndroidApiInfo>
34+
<AndroidApiInfo Include="v2.3">
35+
<Name>Gingerbread</Name>
36+
<Level>10</Level>
37+
<Id>10</Id>
38+
<Stable>True</Stable>
39+
</AndroidApiInfo>
40+
<AndroidApiInfo Include="v3.0">
41+
<Name>Honeycomb</Name>
42+
<Level>11</Level>
43+
<Id>11</Id>
44+
<Stable>True</Stable>
45+
</AndroidApiInfo>
46+
<AndroidApiInfo Include="v3.1">
47+
<Name>Honeycomb</Name>
48+
<Level>12</Level>
49+
<Id>12</Id>
50+
<Stable>True</Stable>
51+
</AndroidApiInfo>
52+
<AndroidApiInfo Include="v3.2">
53+
<Name>Honeycomb</Name>
54+
<Level>13</Level>
55+
<Id>13</Id>
56+
<Stable>True</Stable>
57+
</AndroidApiInfo>
58+
<AndroidApiInfo Include="v4.0">
59+
<Name>Ice Cream Sandwich</Name>
60+
<Level>14</Level>
61+
<Id>14</Id>
62+
<Stable>True</Stable>
63+
</AndroidApiInfo>
64+
<AndroidApiInfo Include="v4.0.3">
65+
<Name>Ice Cream Sandwich</Name>
66+
<Level>15</Level>
67+
<Id>15</Id>
68+
<Stable>True</Stable>
69+
</AndroidApiInfo>
70+
<AndroidApiInfo Include="v4.1">
71+
<Name>Jelly Bean</Name>
72+
<Level>16</Level>
73+
<Id>16</Id>
74+
<Stable>True</Stable>
75+
</AndroidApiInfo>
76+
<AndroidApiInfo Include="v4.2">
77+
<Name>Jelly Bean</Name>
78+
<Level>17</Level>
79+
<Id>17</Id>
80+
<Stable>True</Stable>
81+
</AndroidApiInfo>
82+
<AndroidApiInfo Include="v4.3">
83+
<Name>Jelly Bean</Name>
84+
<Level>18</Level>
85+
<Id>18</Id>
86+
<Stable>True</Stable>
87+
</AndroidApiInfo>
88+
<AndroidApiInfo Include="v4.4">
89+
<Name>Kit Kat</Name>
90+
<Level>19</Level>
91+
<Id>19</Id>
92+
<Stable>True</Stable>
93+
</AndroidApiInfo>
94+
<AndroidApiInfo Include="v4.4.87">
95+
<Name>Kit Kat + Wear support</Name>
96+
<Level>20</Level>
97+
<Id>20</Id>
98+
<Stable>True</Stable>
99+
</AndroidApiInfo>
100+
<AndroidApiInfo Include="v5.0">
101+
<Name>Lollipop</Name>
102+
<Level>21</Level>
103+
<Id>21</Id>
104+
<Stable>True</Stable>
105+
</AndroidApiInfo>
106+
<AndroidApiInfo Include="v5.1">
107+
<Name>Lollipop</Name>
108+
<Level>22</Level>
109+
<Id>22</Id>
110+
<Stable>True</Stable>
111+
</AndroidApiInfo>
112+
<AndroidApiInfo Include="v6.0">
113+
<Name>Marshmallow</Name>
114+
<Level>23</Level>
115+
<Id>23</Id>
116+
<Stable>True</Stable>
117+
</AndroidApiInfo>
118+
<AndroidApiInfo Include="v7.0">
119+
<Name>Nougat</Name>
120+
<Level>24</Level>
121+
<Id>24</Id>
122+
<Stable>True</Stable>
123+
</AndroidApiInfo>
124+
<AndroidApiInfo Include="v7.1">
125+
<Name>Nougat</Name>
126+
<Level>25</Level>
127+
<Id>25</Id>
128+
<Stable>True</Stable>
129+
</AndroidApiInfo>
130+
<AndroidApiInfo Include="v8.0">
131+
<Name>O Preview</Name>
132+
<Level>26</Level>
133+
<Id>O</Id>
134+
<Stable>False</Stable>
135+
</AndroidApiInfo>
136+
</ItemGroup>
137+
</Project>

src/Mono.Android/Mono.Android.targets

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<UsingTask AssemblyFile="..\..\bin\Build$(Configuration)\xa-prep-tasks.dll" TaskName="Xamarin.Android.BuildTools.PrepTasks.ReplaceFileContents" />
44
<Import Project="..\..\build-tools\scripts\XAVersionInfo.targets" />
5+
<Import Project="Mono.Android.projitems" />
56
<ItemGroup>
67
<Compile Include="$(IntermediateOutputPath)AssemblyInfo.cs" />
78
</ItemGroup>
@@ -120,6 +121,31 @@
120121
Overwrite="True"
121122
/>
122123
</Target>
124+
<Target Name="_GenerateAndroidApiInfo"
125+
BeforeTargets="_GenerateFrameworkList"
126+
Inputs="$(MSBuildProjectFullPath)"
127+
Outputs="$(OutputPath)AndroidApiInfo.xml">
128+
<MakeDir Directories="$(OutputPath)" />
129+
<ItemGroup>
130+
<_ApiInfo
131+
Condition=" '%(Identity)' == '$(AndroidFrameworkVersion)' "
132+
Include="@(AndroidApiInfo)"
133+
/>
134+
<_Line Include="&lt;AndroidApiInfo&gt;" />
135+
<_Line Include="@(_ApiInfo->' &lt;Id>%(Id)&lt;/Id>')" />
136+
<_Line Include="@(_ApiInfo->' &lt;Level>%(Level)&lt;/Level>')" />
137+
<_Line Include="@(_ApiInfo->' &lt;Name>%(Name)&lt;/Name>')" />
138+
<_Line Include="@(_ApiInfo->' &lt;Version>%(Identity)&lt;/Version>')" />
139+
<_Line Include="@(_ApiInfo->' &lt;Stable>%(Stable)&lt;/Stable>')" />
140+
<_Line Include="&lt;/AndroidApiInfo&gt;" />
141+
</ItemGroup>
142+
<Message Text="# jonp: _Line=@(_Line)" />
143+
<WriteLinesToFile
144+
File="$(OutputPath)AndroidApiInfo.xml"
145+
Lines="@(_Line)"
146+
Overwrite="True"
147+
/>
148+
</Target>
123149
<Target Name="_CleanBinding"
124150
AfterTargets="Clean">
125151
<RemoveDir Directories="$(IntermediateOutputPath)" />

src/Mono.Android/Test/Resources/Resource.designer.cs

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Xamarin.Android.Build.Tasks/Tasks/CheckTargetFrameworks.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ int ExtractApiLevel(DirectoryAssemblyResolver res, ITaskItem ass)
3434
var value = p.Value.ToString ();
3535
if (value.StartsWith ("MonoAndroid")) {
3636
var values = value.Split ('=');
37-
return AndroidVersion.TryOSVersionToApiLevel (values[1]);
37+
return MonoAndroidHelper.SupportedVersions.GetApiLevelFromFrameworkVersion (values [1]) ?? 0;
3838
}
3939
}
4040
break;
@@ -61,9 +61,9 @@ public override bool Execute ()
6161
}
6262
}
6363

64-
var mainapiLevel = AndroidVersion.TryOSVersionToApiLevel (TargetFrameworkVersion);
64+
var mainapiLevel = MonoAndroidHelper.SupportedVersions.GetApiLevelFromFrameworkVersion (TargetFrameworkVersion);
6565
foreach (var item in apiLevels.Where (x => mainapiLevel < x.Value)) {
66-
var itemOSVersion = AndroidVersion.TryApiLevelToOSVersion (item.Value);
66+
var itemOSVersion = MonoAndroidHelper.SupportedVersions.GetFrameworkVersionFromApiLevel (item.Value);
6767
Log.LogWarning (null, "XA0105", null, ProjectFile, 0, 0, 0, 0,
6868
"The $(TargetFrameworkVersion) for {0} (v{1}) is greater than the $(TargetFrameworkVersion) for your project ({2}). " +
6969
"You need to increase the $(TargetFrameworkVersion) for your project.", Path.GetFileName (item.Key.ItemSpec), itemOSVersion, TargetFrameworkVersion);

src/Xamarin.Android.Build.Tasks/Tasks/GeneratePackageManagerJava.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public override bool Execute ()
9393
// Write the platform api apk we need
9494
pkgmgr.WriteLine ("\tpublic static final String ApiPackageName = {0};", shared_runtime
9595
? string.Format ("\"Mono.Android.Platform.ApiLevel_{0}\"",
96-
MonoDroidSdk.GetApiLevelForFrameworkVersion (TargetFrameworkVersion))
96+
MonoAndroidHelper.SupportedVersions.GetApiLevelFromFrameworkVersion (TargetFrameworkVersion))
9797
: "null");
9898
pkgmgr.WriteLine ("}");
9999
}

src/Xamarin.Android.Build.Tasks/Tasks/GetJavaPlatformJar.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ string GetTargetSdkVersion (string target, XAttribute target_sdk)
118118
message: "AndroidManifest.xml //uses-sdk/@android:targetSdkVersion '{0}' is less than $(TargetFrameworkVersion) '{1}'. Using API-{2} for ACW compilation.",
119119
messageArgs: new[]{
120120
targetSdkVersion,
121-
MonoDroidSdk.GetFrameworkVersionForApiLevel (targetFrameworkVersion),
121+
MonoAndroidHelper.SupportedVersions.GetIdFromFrameworkVersion (targetFrameworkVersion),
122122
MonoAndroidHelper.GetPlatformApiLevelName (targetFrameworkVersion),
123123
}
124124
);

src/Xamarin.Android.Build.Tasks/Tasks/ReadResolvedSdksCache.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public bool RunTask ()
145145

146146
MonoAndroidHelper.TargetFrameworkDirectories = ReferenceAssemblyPaths;
147147

148-
MonoAndroidHelper.RefreshMonoDroidSdk (MonoAndroidToolsPath, MonoAndroidBinPath, ReferenceAssemblyPaths);
148+
MonoAndroidHelper.RefreshSupportedVersions (ReferenceAssemblyPaths);
149149
MonoAndroidHelper.RefreshAndroidSdk (AndroidSdkPath, AndroidNdkPath, JavaSdkPath);
150150

151151
return !Log.HasLoggedErrors;

src/Xamarin.Android.Build.Tasks/Tasks/ResolveSdksTask.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public bool RunTask ()
148148
}
149149
MonoAndroidBinPath = MonoAndroidHelper.GetOSBinPath () + Path.DirectorySeparatorChar;
150150

151-
MonoAndroidHelper.RefreshMonoDroidSdk (MonoAndroidToolsPath, null, ReferenceAssemblyPaths);
151+
MonoAndroidHelper.RefreshSupportedVersions (ReferenceAssemblyPaths);
152152
MonoAndroidHelper.RefreshAndroidSdk (AndroidSdkPath, AndroidNdkPath, JavaSdkPath);
153153

154154
this.AndroidNdkPath = AndroidSdk.AndroidNdkPath;
@@ -236,8 +236,7 @@ public bool RunTask ()
236236
if (!ValidateApiLevels ())
237237
return false;
238238

239-
string frameworksPath = Path.GetDirectoryName (MonoDroidSdk.FrameworkPath);
240-
if (!Directory.Exists (Path.Combine (frameworksPath, TargetFrameworkVersion))) {
239+
if (!MonoAndroidHelper.SupportedVersions.FrameworkDirectories.Any (p => Directory.Exists (Path.Combine (p, TargetFrameworkVersion)))) {
241240
Log.LogError (
242241
subcategory: string.Empty,
243242
errorCode: "XA0001",
@@ -316,7 +315,7 @@ public bool RunTask ()
316315

317316
Version GetJavaVersionForFramework (string targetFrameworkVersion)
318317
{
319-
var apiLevel = AndroidVersion.TryOSVersionToApiLevel (targetFrameworkVersion);
318+
var apiLevel = MonoAndroidHelper.SupportedVersions.GetApiLevelFromFrameworkVersion (targetFrameworkVersion);
320319
if (apiLevel >= 24)
321320
return new Version (1, 8);
322321
else if (apiLevel == 23)
@@ -416,7 +415,7 @@ bool ValidateApiLevels ()
416415

417416
if (!string.IsNullOrWhiteSpace (TargetFrameworkVersion)) {
418417
TargetFrameworkVersion = TargetFrameworkVersion.Trim ();
419-
string apiLevel = MonoDroidSdk.GetApiLevelForFrameworkVersion (TargetFrameworkVersion);
418+
string apiLevel = MonoAndroidHelper.SupportedVersions.GetIdFromFrameworkVersion (TargetFrameworkVersion);
420419
if (apiLevel == null) {
421420
Log.LogCodedError ("XA0000",
422421
"Could not determine API level for $(TargetFrameworkVersion) of '{0}'.",
@@ -463,7 +462,7 @@ string GetMaxSupportedApiLevel (string apiLevel)
463462
foreach (string versionedDir in ReferenceAssemblyPaths) {
464463
string parent = Path.GetDirectoryName (versionedDir.TrimEnd (Path.DirectorySeparatorChar));
465464
for ( int l = level ; l > 0; l--) {
466-
string tfv = MonoDroidSdk.GetFrameworkVersionForApiLevel (l.ToString ());
465+
string tfv = MonoAndroidHelper.SupportedVersions.GetFrameworkVersionFromApiLevel (l);
467466
if (tfv == null)
468467
continue;
469468
string dir = Path.Combine (parent, tfv);
@@ -476,8 +475,8 @@ string GetMaxSupportedApiLevel (string apiLevel)
476475

477476
string GetTargetFrameworkVersionFromApiLevel ()
478477
{
479-
string targetFramework = MonoDroidSdk.GetFrameworkVersionForApiLevel (SupportedApiLevel) ??
480-
MonoDroidSdk.GetFrameworkVersionForApiLevel (AndroidApiLevel);
478+
string targetFramework = MonoAndroidHelper.SupportedVersions.GetFrameworkVersionFromId (SupportedApiLevel) ??
479+
MonoAndroidHelper.SupportedVersions.GetFrameworkVersionFromId (AndroidApiLevel);
481480
if (targetFramework != null)
482481
return targetFramework;
483482
Log.LogCodedError ("XA0000",

src/Xamarin.Android.Build.Tasks/Utilities/MonoAndroidHelper.cs

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ public class MonoAndroidHelper
2626
// Set in ResolveSdks.Execute();
2727
// Requires that ResolveSdks.Execute() run before anything else
2828
public static string[] TargetFrameworkDirectories;
29+
public static AndroidVersions SupportedVersions;
30+
2931
readonly static byte[] Utf8Preamble = System.Text.Encoding.UTF8.GetPreamble ();
3032

3133
public static int RunProcess (string name, string args, DataReceivedEventHandler onOutput, DataReceivedEventHandler onError)
@@ -83,15 +85,9 @@ public static void RefreshAndroidSdk (string sdkPath, string ndkPath, string jav
8385
AndroidSdk.Refresh (sdkPath, ndkPath, javaPath);
8486
}
8587

86-
public static void RefreshMonoDroidSdk (string toolsPath, string binPath, string[] referenceAssemblyPaths)
88+
public static void RefreshSupportedVersions (string[] referenceAssemblyPaths)
8789
{
88-
MonoDroidSdk.Refresh (toolsPath, binPath,
89-
(from refPath in referenceAssemblyPaths ?? new string [0]
90-
where !string.IsNullOrEmpty (refPath)
91-
let path = refPath.TrimEnd (Path.DirectorySeparatorChar)
92-
where File.Exists (Path.Combine (path, "mscorlib.dll"))
93-
select path)
94-
.FirstOrDefault ());
90+
SupportedVersions = new AndroidVersions (referenceAssemblyPaths);
9591
}
9692
#endif // MSBUILD
9793

@@ -469,24 +465,18 @@ internal static IEnumerable<string> GetFrameworkAssembliesToTreatAsUserAssemblie
469465
// We may have to use this in the future too.
470466
public static string GetPlatformApiLevelName (string platformApiLevel)
471467
{
472-
switch (platformApiLevel.Trim ()) {
473-
//case "26":
474-
// return "O";
475-
default:
476-
return platformApiLevel;
468+
int apiLevel;
469+
if (int.TryParse (platformApiLevel, out apiLevel)) {
470+
return SupportedVersions.GetIdFromApiLevel (apiLevel);
477471
}
472+
return platformApiLevel;
478473
}
479474

480475
// It used to replace "21" with "L" when it was preview, or "23" with "MNC" (ditto).
481476
// We may have to use this in the future too.
482477
public static string GetPlatformApiLevel (string platformApiLevelName)
483478
{
484-
switch (platformApiLevelName.Trim ()) {
485-
//case "O":
486-
// return "26";
487-
default:
488-
return platformApiLevelName;
489-
}
479+
return SupportedVersions.GetApiLevelFromId (platformApiLevelName)?.ToString ();
490480
}
491481

492482
public static Dictionary<string, string> LoadAcwMapFile (string acwPath)

0 commit comments

Comments
 (0)