Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ public override bool Execute ()
.OrderBy (v => v)) {
writer.WriteStartElement ("AndroidSdkSupportedTargetPlatformVersion");
writer.WriteAttributeString ("Include", apiLevel.ToString ("0.0", CultureInfo.InvariantCulture));
if (apiLevel < TargetApiLevel) {
writer.WriteAttributeString ("DefineConstantsOnly", "true");
}
writer.WriteEndElement (); // </AndroidSdkSupportedTargetPlatformVersion>
}
writer.WriteStartElement ("SdkSupportedTargetPlatformVersion");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and
<PropertyGroup>
<AndroidNETSdkVersion>@ANDROID_PACK_VERSION_LONG@</AndroidNETSdkVersion>
<XamarinAndroidVersion>@ANDROID_PACK_VERSION_LONG@</XamarinAndroidVersion>
<_AndroidLatestStableApiLevel>@ANDROID_LATEST_STABLE_API_LEVEL@</_AndroidLatestStableApiLevel>
</PropertyGroup>
<PropertyGroup>
<_AndroidTargetingPackId Condition="$(TargetPlatformVersion.EndsWith('.0'))">$(TargetPlatformVersion.Substring(0, $(TargetPlatformVersion.LastIndexOf('.0'))))</_AndroidTargetingPackId>
<_AndroidTargetingPackId Condition="'$(_AndroidTargetingPackId)' == ''">$(TargetPlatformVersion)</_AndroidTargetingPackId>
<_AndroidRuntimePackId Condition=" '$(_AndroidTargetingPackId)' &lt; '@ANDROID_LATEST_STABLE_API_LEVEL@' ">@ANDROID_LATEST_STABLE_API_LEVEL@</_AndroidRuntimePackId>
<!-- NOTE: adjust if a TargetFramework supports multiple API levels -->
<_AndroidErrorOnTargetPlatformVersion Condition=" '$(_AndroidTargetingPackId)' != '$(_AndroidLatestStableApiLevel)' ">$(_AndroidTargetingPackId)</_AndroidErrorOnTargetPlatformVersion>
<_AndroidTargetingPackId Condition=" '$(_AndroidTargetingPackId)' != '$(_AndroidLatestStableApiLevel)' ">$(_AndroidLatestStableApiLevel)</_AndroidTargetingPackId>
<_AndroidRuntimePackId Condition=" '$(_AndroidRuntimePackId)' == '' ">$(_AndroidTargetingPackId)</_AndroidRuntimePackId>
<_AndroidRuntimePackId Condition=" '$(_AndroidRuntimePackId)' != '$(_AndroidLatestStableApiLevel)' ">$(_AndroidLatestStableApiLevel)</_AndroidRuntimePackId>
</PropertyGroup>
<ItemGroup>
<KnownFrameworkReference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,20 @@ public void IfAndroidJarDoesNotExistThrowXA5207 ([Values(true, false)] bool buil
Directory.Delete (AndroidSdkDirectory, recursive: true);
}

[Test]
public void InvalidTargetPlatformVersion ([Values ("android33", "android99.0")] string platformVersion)
{
const string targetFramework = "net9.0";
var project = new XamarinAndroidApplicationProject {
TargetFramework = $"{targetFramework}-{platformVersion}",
};
using var builder = CreateApkBuilder ();
builder.ThrowOnBuildFailure = false;
Assert.IsFalse (builder.Build (project), "build should fail");

Assert.IsTrue (builder.LastBuildOutput.ContainsText ("error NETSDK1140:"), "NETSDK1140 should have been raised.");
}

[Test]
public void XA4212 ()
{
Expand Down