Uh oh!
There was an error while loading. Please reload this page.
[XABT] Prefer SupportedOSPlatformVersion over minSdkVersion - #8026
Conversation
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I noticed that we were not writing a valid `minSdkVersion` value to the generated `AndroidManifest.xml` file for projects which included a manifest that declared a `targetSdkVersion`. In these cases, we would always write a `minSdkVersion` of `19` to the manifest file, as this is the min version that our NDK supports. Fix this to always write the value of `$(SupportedOSPlatformVersion)`. If this value is not explicitly set in the project file, it will default to `$(TargetPlatformVersion)`. A couple of multidex related tests have been added to the ignore list as they are only valid with a minSdkVersion of 20 or lower.
NDKMinimumApiAvailable over SupportedOSPlatformVersionNDKMinimumApiAvailable over SupportedOSPlatformVersionSupportedOSPlatformVersion over minSdkVersionUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| message: Properties.Resources.XA4216_MinSdkVersion, | ||
| messageArgs: new object [] { min_sdk?.Value, XABuildConfig.NDKMinimumApiAvailable } | ||
| ); | ||
| if (min_sdk != null) { |
There was a problem hiding this comment.
Aside: the amount of indentation going on here has my crying out for a helper method 3 levels of indentation ago…
| } | ||
| } | ||
| if (target_sdk != null && (!int.TryParse (target_sdk.Value, out int targetSdkVersion) || targetSdkVersion < XABuildConfig.NDKMinimumApiAvailable)) { | ||
| if (target_sdk != null && (!int.TryParse (target_sdk.Value, out int targetSdkVersion) || targetSdkVersion < XABuildConfig.AndroidMinimumDotNetApiLevel)) { |
There was a problem hiding this comment.
Similar/different to https://github.com/xamarin/xamarin-android/pull/8026/files#r1199283399 , if targetSdkVersion is < $(AndroidMinimumDotNetApiLevel), should this be an error?
This doesn't feel reasonable, and I wonder what Java would do with:
<uses-sdkandroid:minSdkVersion="21"android:targetSdkVersion="19" />Maybe this should remain a warning? This just feels bananas to me.
There was a problem hiding this comment.
Maybe both XA4216 warnings should be repurposed and converted to errors?
There was a problem hiding this comment.
It seems that Android studio does not produce a warning or error when targetSdkVersion < minSdkVersion, so we can probably leave the targetSdkVersion condition untouched.
I'll try to merge XA1036 into XA4216_MinSdkVersion however, as keeping that warning is redundant.
There was a problem hiding this comment.
I've repurposed XA4216, it will continue to warn in the case of targetSdkVersion, but will now produce errors for:
- SupportedOSPlatformVersion < minimum version supported
- minSdkVersion < minimum version supported
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
jonpryor
commented
May 19, 2023
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
pjcollins
commented
May 24, 2023
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
pjcollins
commented
May 24, 2023
Looks like the only test failures are |
| var failedToParseMinSdk = !int.TryParse (min_sdk.Value, out int minSdkVersion); | ||
| if (failedToParseMinSdk || minSdkVersion < XABuildConfig.AndroidMinimumDotNetApiLevel) { | ||
| Log.LogCodedError ("XA4216", Properties.Resources.XA4216_MinSdkVersion, min_sdk?.Value, XABuildConfig.AndroidMinimumDotNetApiLevel); |
There was a problem hiding this comment.
Is it possible to provide a filename for the error message?
There was a problem hiding this comment.
We could extend https://github.com/xamarin/xamarin-android-tools/blob/main/src/Microsoft.Android.Build.BaseTasks/MSBuildExtensions.cs#L142 for the AndroidManifest case, but I don't know of an easy way to report what file is setting SupportedOSPlatformVersion (it will likely be set in the project file, but could be in a directory.build.props or any other import).
There was a problem hiding this comment.
I added dotnet/android-tools#209 so that we can better link to the manifest file in this error.
| } | ||
| if (failedToParseMinSdk || minSdkVersion != supportedOsPlatformVersionAsInt) { | ||
| Log.LogCodedError ("XA1036", Properties.Resources.XA1036, min_sdk?.Value, SupportedOSPlatformVersion); |
There was a problem hiding this comment.
Is it possible to provide a filename for the error message?
There was a problem hiding this comment.
I don't know of an easy way to report what file is setting SupportedOSPlatformVersion (it will likely be set in the project file, but could be in a directory.build.props or any other import).
jonpryor
commented
May 26, 2023
squash-and-merge commit message: Fixes: https://github.com/xamarin/xamarin-android/issues/8040
I noticed that we were not writing a supported (by us)
`//uses-sdk/@android:minSdkVersion` value to the generated
`AndroidManifest.xml` file for projects which included a manifest
that declared a `targetSdkVersion`. In these cases, we would
always write a `//uses-sdk/@android:minSdkVersion` value of `21` to
`AndroidManifest.xml`, as this is the minimum version that MonoVM
supports.
Fix this to always use the value of `$(SupportedOSPlatformVersion)`
as the `minSdkVersion` attribute in the `AndroidManifest.xml` file.
If this value is not explicitly set in the project file, it will now
default to `$(AndroidMinimumSupportedApiLevel)` instead of
`$(TargetPlatformVersion)`.
The `XA4216` error/warning code has been expanded+repurposed.
The warning that would display when the `minSdkVersion` attribute in
`AndroidManifest.xml` was less than our minimum supported API level
has been converted into an error:
error XA4216: The deployment target '19' is not supported (the minimum is '21').Please increase (or remove) the //uses-sdk/@android:minSdkVersion value in your project file.
A similar error is now reported when `$(SupportedOSPlatformVersion)`
is less than `$(AndroidMinimumSupportedApiLevel)`error XA4216: The deployment target '19' is not supported (the minimum is '21').Please increase the $(SupportedOSPlatformVersion) property value in your project file.
An error condition has been added for when
`//uses-sdk/@android:minSdkVersion` in `AndroidManifest.xml` does not
match `$(SupportedOSPlatformVersion)`:
error XA1036: AndroidManifest.xml //uses-sdk/@android:minSdkVersion '19' does not match the $(SupportedOSPlatformVersion) value '21.0' in the project file (if there is no $(SupportedOSPlatformVersion) value in the project file, then a default value has been assumed).Either change the value in the AndroidManifest.xml to match the $(SupportedOSPlatformVersion) value, or remove the value in the AndroidManifest.xml (and add a $(SupportedOSPlatformVersion) value to the project file if it doesn't already exist).
A few multidex related tests have been updated/removed as they are
only valid with a minSdkVersion of 20 or lower. |
pjcollins
commented
May 26, 2023
One comment for the message:
We were previously writing |
* main: [XABT] Prefer `SupportedOSPlatformVersion` over `minSdkVersion` (dotnet#8026) Bump to xamarin/Java.Interop/main@72b041a (dotnet#8089) Bump LibZipSharp to 3.0.0 (dotnet#8061) Bump to xamarin/Java.Interop/main@8c9eece (dotnet#8073) [profiled-aot] update AOT profile for .NET 8 Preview 5 (dotnet#8077) Localized file check-in by OneLocBuild Task (dotnet#8078) Bump to dotnet/installer@6150605bd0 8.0.100-preview.6.23276.3 (dotnet#8083)
Context: #8040
I noticed that we were not writing a valid
minSdkVersionvalue to thegenerated
AndroidManifest.xmlfile for projects which included amanifest that declared a
targetSdkVersion. In these cases, we wouldalways write a
minSdkVersionof19to the manifest file, as this isthe min version that our NDK supports.
Fix this to always use the value of
$(SupportedOSPlatformVersion)asthe
minSdkVersionelement in theAndroidManifest.xmlfile. If thisvalue is not explicitly set in the project file, it will now default to
$(AndroidMinimumSupportedApiLevel)instead of$(TargetPlatformVersion).The
XA4216error/warning code has been repurposed.The warning that would display when the
minSdkVersionelement inAndroidManifest.xmlwas less than our minimum supported API level hasbeen converted into an error:
An error condition has been added for when the
$(SupportedOSPlatformVersion)property value is less than$(AndroidMinimumSupportedApiLevel):An error condition has been added for when the
minSdkVersionelementin
AndroidManifest.xmldoes not match$(SupportedOSPlatformVersion):A few multidex related tests have been updated/removed as they are only
valid with a minSdkVersion of 20 or lower.