Skip to content

Commit 3456409

Browse files
grendellojonpryor
authored andcommitted
Revert "[build] Use API-21 for all native builds (#4584)"
Context: https://docs.microsoft.com/en-us/xamarin/get-started/supported-platforms?tabs=windows Context: https://github.com/dotnet/maui#xamarinforms-vs-net-maui This reverts commit a648981. Xamarin.Forms advertises a supported minimum API level of API-19, which commit a648981 removed support for. This change complicates the life of the Xamarin.Forms team. We will eventually drop support for API-19 -- certainly as part of .NET 5/6 -- but for now preserve API-19 compatibility.
1 parent 01084b1 commit 3456409

File tree

11 files changed

+28
-63
lines changed

11 files changed

+28
-63
lines changed

Configuration.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
<TargetFrameworkVersion Condition=" '$(TargetFrameworkVersion)' == '' And '$(UsingMicrosoftNETSdk)' != 'true' ">v4.7.1</TargetFrameworkVersion>
2020
<!-- Used by the `build-tools/create-vsix` build so that `Mono.Android.Export.dll`/etc. are only included *once* -->
2121
<!-- Should correspond to the first value from `$(API_LEVELS)` in `build-tools/api-xml-adjuster/Makefile` -->
22-
<AndroidFirstFrameworkVersion Condition="'$(AndroidFirstFrameworkVersion)' == ''">v5.0</AndroidFirstFrameworkVersion>
23-
<AndroidFirstApiLevel Condition="'$(AndroidFirstApiLevel)' == ''">21</AndroidFirstApiLevel>
22+
<AndroidFirstFrameworkVersion Condition="'$(AndroidFirstFrameworkVersion)' == ''">v4.4</AndroidFirstFrameworkVersion>
23+
<AndroidFirstApiLevel Condition="'$(AndroidFirstApiLevel)' == ''">19</AndroidFirstApiLevel>
2424
<AndroidFirstPlatformId Condition="'$(AndroidFirstPlatformId)' == ''">$(AndroidFirstApiLevel)</AndroidFirstPlatformId>
2525
<_IsRunningNuGetRestore Condition="$(RestoreTaskAssemblyFile.EndsWith('NuGet.exe', StringComparison.InvariantCultureIgnoreCase))">True</_IsRunningNuGetRestore>
2626
<!-- *Latest* *stable* API level binding that we support; used when building src/Xamarin.Android.Build.Tasks -->

Documentation/release-notes/4584.md

Lines changed: 0 additions & 16 deletions
This file was deleted.

build-tools/api-merge/merge-configuration.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
<File Path="api-R.xml.in" Level="R" />
2222
</Inputs>
2323
<Outputs>
24+
<File Path="android-19\mcw\api.xml" LastLevel="19" />
25+
<File Path="android-20\mcw\api.xml" LastLevel="20" />
2426
<File Path="android-21\mcw\api.xml" LastLevel="21" />
2527
<File Path="android-22\mcw\api.xml" LastLevel="22" />
2628
<File Path="android-23\mcw\api.xml" LastLevel="23" />

build-tools/api-xml-adjuster/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ API_XML_TOOL = $(BUILDBIN)/api-xml-adjuster.exe
1717
RUNTIME = mono --debug
1818
RUN_CLASS_PARSE = $(RUNTIME) $(CLASS_PARSE)
1919
RUN_API_XML_TOOL = $(RUNTIME) $(API_XML_TOOL)
20-
API_LEVELS = 21 22 23 24 25 26 27 28 29 R
20+
API_LEVELS = 10 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 R
2121

2222
XML_OUTPUT_DIR = .
2323

build-tools/xaprepare/xaprepare/ConfigAndData/BuildAndroidPlatforms.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ class BuildAndroidPlatforms
2727
new AndroidPlatform (apiName: "Jelly Bean", apiLevel: 16, platformID: "16", include: "v4.1"),
2828
new AndroidPlatform (apiName: "Jelly Bean", apiLevel: 17, platformID: "17", include: "v4.2"),
2929
new AndroidPlatform (apiName: "Jelly Bean", apiLevel: 18, platformID: "18", include: "v4.3"),
30-
new AndroidPlatform (apiName: "Kit Kat", apiLevel: 19, platformID: "19", include: "v4.4"),
31-
new AndroidPlatform (apiName: "Kit Kat + Wear support", apiLevel: 20, platformID: "20", include: "v4.4.87"),
30+
new AndroidPlatform (apiName: "Kit Kat", apiLevel: 19, platformID: "19", include: "v4.4", framework: "v4.4"),
31+
new AndroidPlatform (apiName: "Kit Kat + Wear support", apiLevel: 20, platformID: "20", include: "v4.4.87", framework: "v4.4.87"),
3232
new AndroidPlatform (apiName: "Lollipop", apiLevel: 21, platformID: "21", include: "v5.0", framework: "v5.0"),
3333
new AndroidPlatform (apiName: "Lollipop", apiLevel: 22, platformID: "22", include: "v5.1", framework: "v5.1"),
3434
new AndroidPlatform (apiName: "Marshmallow", apiLevel: 23, platformID: "23", include: "v6.0", framework: "v6.0"),
@@ -42,9 +42,9 @@ class BuildAndroidPlatforms
4242
};
4343

4444
public static readonly Dictionary<string, uint> NdkMinimumAPI = new Dictionary<string, uint> {
45-
{ AbiNames.TargetJit.AndroidArmV7a, 21 },
45+
{ AbiNames.TargetJit.AndroidArmV7a, 16 },
4646
{ AbiNames.TargetJit.AndroidArmV8a, 21 },
47-
{ AbiNames.TargetJit.AndroidX86, 21 },
47+
{ AbiNames.TargetJit.AndroidX86, 16 },
4848
{ AbiNames.TargetJit.AndroidX86_64, 21 },
4949
};
5050
}

build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/AndroidToolchain.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,8 @@ public AndroidToolchain ()
4646

4747
new AndroidToolchainComponent ("docs-24_r01", destDir: "docs", pkgRevision: "1"),
4848
new AndroidToolchainComponent ("android_m2repository_r47", destDir: Path.Combine ("extras", "android", "m2repository"), pkgRevision: "47.0.0"),
49-
50-
// NOTE: for some reason x86-29_r07 and x86_64-29_r07 zips are tagged with the OS name, JUST these system images - when
51-
// updating to a latter version check if that's changed or not.
49+
new AndroidToolchainComponent ("x86-29_r06", destDir: Path.Combine ("system-images", "android-29", "default", "x86"), relativeUrl: new Uri ("sys-img/android/", UriKind.Relative), pkgRevision: "6"),
5250
new AndroidToolchainComponent ($"x86_64-29_r07-{osTag}", destDir: Path.Combine ("system-images", "android-29", "default", "x86_64"), relativeUrl: new Uri ("sys-img/android/", UriKind.Relative), pkgRevision: "7"),
53-
new AndroidToolchainComponent ($"x86-29_r07-{osTag}", destDir: Path.Combine ("system-images", "android-29", "default", "x86"), relativeUrl: new Uri ("sys-img/android/", UriKind.Relative), pkgRevision: "7"),
5451
new AndroidToolchainComponent ($"android-ndk-r{AndroidNdkVersion}-{osTag}-x86_64", destDir: AndroidNdkDirectory, pkgRevision: AndroidPkgRevision),
5552
new AndroidToolchainComponent ($"build-tools_r{XABuildToolsVersion}-{altOsTag}", destDir: Path.Combine ("build-tools", XABuildToolsFolder), isMultiVersion: true),
5653
new AndroidToolchainComponent ($"commandlinetools-{cltOsTag}-{CommandLineToolsVersion}",

build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,17 +114,10 @@ GeneratedFile Get_XABuildConfig_cs (Context context)
114114
{
115115
const string OutputFileName = "XABuildConfig.cs";
116116

117-
uint minimumApiAvailable = UInt32.MaxValue;
118-
foreach (uint api in BuildAndroidPlatforms.NdkMinimumAPI.Values) {
119-
if (api > minimumApiAvailable)
120-
continue;
121-
minimumApiAvailable = api;
122-
}
123-
124117
var replacements = new Dictionary<string, string> (StringComparer.Ordinal) {
125118
{ "@NDK_REVISION@", context.BuildInfo.NDKRevision },
126119
{ "@NDK_RELEASE@", BuildAndroidPlatforms.AndroidNdkVersion },
127-
{ "@NDK_MINIMUM_API_AVAILABLE@", minimumApiAvailable.ToString () },
120+
{ "@NDK_MINIMUM_API_AVAILABLE@", context.BuildInfo.NDKMinimumApiAvailable },
128121
{ "@NDK_VERSION_MAJOR@", context.BuildInfo.NDKVersionMajor },
129122
{ "@NDK_VERSION_MINOR@", context.BuildInfo.NDKVersionMinor },
130123
{ "@NDK_VERSION_MICRO@", context.BuildInfo.NDKVersionMicro },

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,7 @@ public void BuildAotApplicationAndÜmläüts (string supportedAbis, bool enableL
997997
// LLVM passes a direct path to libc.so, and we need to use the libc.so
998998
// which corresponds to the *minimum* SDK version specified in AndroidManifest.xml
999999
// Since we overrode minSdkVersion=16, that means we should use libc.so from android-16.
1000-
StringAssertEx.ContainsRegex (@"\s*\[aot-compiler stdout].*android-21.arch-.*.usr.lib.libc\.so", b.LastBuildOutput, "AOT+LLVM should use libc.so from minSdkVersion!");
1000+
StringAssertEx.ContainsRegex (@"\s*\[aot-compiler stdout].*android-16.arch-.*.usr.lib.libc\.so", b.LastBuildOutput, "AOT+LLVM should use libc.so from minSdkVersion!");
10011001
}
10021002
foreach (var abi in supportedAbis.Split (new char [] { ';' })) {
10031003
var libapp = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath,
@@ -1127,32 +1127,25 @@ public void BuildProguardEnabledProject ([Values (true, false)] bool isRelease,
11271127

11281128
XamarinAndroidApplicationProject CreateMultiDexRequiredApplication (string debugConfigurationName = "Debug", string releaseConfigurationName = "Release")
11291129
{
1130-
const int NumberOfMethods = (32 * 1024) - 1;
11311130
var proj = new XamarinAndroidApplicationProject (debugConfigurationName, releaseConfigurationName);
11321131
proj.OtherBuildItems.Add (new BuildItem (AndroidBuildActions.AndroidJavaSource, "ManyMethods.java") {
11331132
TextContent = () => "public class ManyMethods { \n"
1134-
+ string.Join (Environment.NewLine, Enumerable.Range (0, NumberOfMethods).Select (i => "public void method" + i + "() {}"))
1133+
+ string.Join (Environment.NewLine, Enumerable.Range (0, 32768).Select (i => "public void method" + i + "() {}"))
11351134
+ "}",
11361135
Encoding = Encoding.ASCII
11371136
});
11381137
proj.OtherBuildItems.Add (new BuildItem (AndroidBuildActions.AndroidJavaSource, "ManyMethods2.java") {
11391138
TextContent = () => "public class ManyMethods2 { \n"
1140-
+ string.Join (Environment.NewLine, Enumerable.Range (0, NumberOfMethods).Select (i => "public void method" + i + "() {}"))
1139+
+ string.Join (Environment.NewLine, Enumerable.Range (0, 32768).Select (i => "public void method" + i + "() {}"))
11411140
+ "}",
11421141
Encoding = Encoding.ASCII
11431142
});
1144-
proj.OtherBuildItems.Add (new BuildItem (AndroidBuildActions.AndroidJavaSource, "ManyMethods3.java") {
1145-
TextContent = () => "public class ManyMethods3 { \n"
1146-
+ string.Join (Environment.NewLine, Enumerable.Range (0, NumberOfMethods).Select (i => "public void method" + i + "() {}"))
1147-
+ "}",
1148-
Encoding = Encoding.ASCII
1149-
});
11501143
return proj;
11511144
}
11521145

11531146
[Test]
11541147
[Category ("Minor")]
1155-
public void BuildApplicationRequiresMultiDex ([Values ("dx", "d8")] string dexTool)
1148+
public void BuildApplicationOver65536Methods ([Values ("dx", "d8")] string dexTool)
11561149
{
11571150
if (dexTool == "d8")
11581151
Assert.Ignore ("The build currently *succeeds* with d8, when API 21 is our minimum.");
@@ -1197,14 +1190,11 @@ public void BuildMultiDexApplication ([Values ("dx", "d8")] string dexTool)
11971190
intermediateDir = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath);
11981191
}
11991192
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
1200-
FileAssert.Exists (Path.Combine (intermediateDir, "android", "bin", "classes.dex"));
1201-
1202-
if (proj.DexTool != "d8") {
1203-
var multidexKeepPath = Path.Combine (intermediateDir, "multidex.keep");
1204-
FileAssert.Exists (multidexKeepPath);
1205-
Assert.IsTrue (File.ReadAllLines (multidexKeepPath).Length > 1, "multidex.keep must contain more than one line.");
1206-
}
1207-
1193+
Assert.IsTrue (File.Exists (Path.Combine (Root, b.ProjectDirectory, intermediateDir, "android/bin/classes.dex")),
1194+
"multidex-ed classes.zip exists");
1195+
var multidexKeepPath = Path.Combine (Root, b.ProjectDirectory, intermediateDir, "multidex.keep");
1196+
Assert.IsTrue (File.Exists (multidexKeepPath), "multidex.keep exists");
1197+
Assert.IsTrue (File.ReadAllLines (multidexKeepPath).Length > 1, "multidex.keep must contain more than one line.");
12081198
Assert.IsTrue (b.LastBuildOutput.ContainsText (Path.Combine (proj.TargetFrameworkVersion, "mono.android.jar")), proj.TargetFrameworkVersion + "/mono.android.jar should be used.");
12091199
Assert.IsFalse (b.LastBuildOutput.ContainsText ("Duplicate zip entry"), "Should not get warning about [META-INF/MANIFEST.MF]");
12101200
}

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/ManifestTest.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,6 @@ public void DirectBootAwareAttribute ()
298298
}
299299
}
300300

301-
// Information about version codes: https://devblogs.microsoft.com/xamarin/advanced-android-versioncode/
302301
static object [] VersionCodeTestSource = new object [] {
303302
new object[] {
304303
/* seperateApk */ false,
@@ -388,7 +387,7 @@ public void DirectBootAwareAttribute ()
388387
/* pattern */ "{abi}{minSDK:00}{versionCode:000}",
389388
/* props */ null,
390389
/* shouldBuild */ true,
391-
/* expected */ "221012;321012",
390+
/* expected */ "216012;316012",
392391
},
393392
new object[] {
394393
/* seperateApk */ true,
@@ -398,7 +397,7 @@ public void DirectBootAwareAttribute ()
398397
/* pattern */ "{abi}{minSDK:00}{screen}{versionCode:000}",
399398
/* props */ "screen=24",
400399
/* shouldBuild */ true,
401-
/* expected */ "22124012;32124012",
400+
/* expected */ "21624012;31624012",
402401
},
403402
new object[] {
404403
/* seperateApk */ true,
@@ -408,7 +407,7 @@ public void DirectBootAwareAttribute ()
408407
/* pattern */ "{abi}{minSDK:00}{screen}{foo:0}{versionCode:000}",
409408
/* props */ "screen=24;foo=$(Foo)",
410409
/* shouldBuild */ true,
411-
/* expected */ "221241012;321241012",
410+
/* expected */ "216241012;316241012",
412411
},
413412
new object[] {
414413
/* seperateApk */ true,
@@ -418,7 +417,7 @@ public void DirectBootAwareAttribute ()
418417
/* pattern */ "{abi}{minSDK:00}{screen}{foo:00}{versionCode:000}",
419418
/* props */ "screen=24;foo=$(Foo)",
420419
/* shouldBuild */ false,
421-
/* expected */ "2212401012;3212401012",
420+
/* expected */ "2162401012;3162401012",
422421
},
423422
};
424423

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/NdkUtilTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public void TestNdkUtil ()
4141
Assert.IsTrue (NdkUtil.ValidateNdkPlatform (log, ndkDir, arch, enableLLVM: false));
4242
Assert.AreEqual (0, errors.Count, "NdkUtil.ValidateNdkPlatform should not have returned false.");
4343
int level = NdkUtil.GetMinimumApiLevelFor (arch, ndkDir);
44-
int expected = 21;
44+
int expected = 16;
4545
Assert.AreEqual (expected, level, $"Min Api Level for {arch} should be {expected}.");
4646
var compilerNoQuotes = NdkUtil.GetNdkTool (ndkDir, arch, "gcc", level);
4747
Assert.AreEqual (0, errors.Count, "NdkUtil.GetNdkTool should not have errored.");

0 commit comments

Comments
 (0)