Skip to content

[templates] Default $(SupportedOSPlatformVersion) to 24. - #9656

Merged
jonpryor merged 1 commit into
mainfrom
os-minimum-24
Jan 10, 2025
Merged

jonpryor merged 1 commit into
mainfrom
os-minimum-24

Conversation

@jpobst

@jpobst jpobst commented Jan 7, 2025

Copy link
Copy Markdown
Contributor

Fixes: #9517
Context: dotnet/android-libraries#767
Context: dotnet/android-libraries#767 (comment)

For .NET 10, update the dotnet new android template so that $(SupportedOSPlatformVersion) is 24, bumping from the current default of 21.

The reason for this is that "desugaring" "moves" Java methods to locations that we don't expect, which can result in AbstractMethodErrors at runtime. Setting the minimum SDK version to >= 24 avoids this desugaring step, preventing the Java methods from being moved in a manner we don't expect, and thus avoiding the AbstractMethodError.

Note that 21 will still be the supported minimum for those that need it, however this will keep most users who do not need to support devices that old from having desugaring issues.

@jpobst

jpobst commented Jan 8, 2025 •

Copy link
Copy Markdown
Contributor Author

This "fixes" the issue going forward. Should we also add a warning when $(SupportedOSPlatformVersion) < 24 to encourage users to update their existing projects?

Edit: I guess this is part of the #9527 proposal.

@jpobst jpobst changed the title [templates] Default $(SupportedOSPlatformVersion) to `24. [templates] Default $(SupportedOSPlatformVersion) to 24. Jan 8, 2025
@jpobst
jpobst marked this pull request as ready for review January 8, 2025 17:54
@jpobst
jpobst requested a review from jonpryor as a code owner January 8, 2025 17:54

@jonathanpeppers jonathanpeppers left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If $(SupportedOSPlatformVersion) is blank, should we also hardcode 24 here?

@jonpryor

jonpryor commented Jan 9, 2025

Copy link
Copy Markdown
Contributor

@jonathanpeppers asked:

If $(SupportedOSPlatformVersion) is blank, should we also hardcode 24 here?

My gut feeling is "no", because it makes sense to me that if it isn't set, it should default to the minimum supported, vs. the "minimum recommended".

My sense of what makes sense may be completely wrong.

Any idea in what scenarios $(SupportedOSPlatformVersion) wouldn't be set? All I can think of is someone manually migrating a legacy Xamarin.Android project to a .NET project.

@jpobst

jpobst commented Jan 9, 2025

Copy link
Copy Markdown
Contributor Author

My gut feeling is "no", because it makes sense to me that if it isn't set, it should default to the minimum supported, vs. the "minimum recommended".

This may depend on if we intend to add a warning when targeting 21. If we do, we probably shouldn't default to a version that generates a warning.

@jonathanpeppers

Copy link
Copy Markdown
Member

I think we can take this as-is for now, and follow up with more with:

@jonpryor
jonpryor merged commit 6754e05 into main Jan 10, 2025
@jonpryor
jonpryor deleted the os-minimum-24 branch January 10, 2025 19:14
grendello added a commit that referenced this pull request Jan 10, 2025
* main:
  Bump to dotnet/sdk@2d6bc4f67d 10.0.100-alpha.1.25060.8 (#9669)
  [templates] Default `$(SupportedOSPlatformVersion)=24`. (#9656)
  Bump to dotnet/sdk@a93a592ce9 10.0.100-alpha.1.25056.1 (#9395)
  LEGO: Pull request (#9667)
  [tests] use the 'TestName' property (#9664)
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 10, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Set $(SupportedOSPlatformVersion)=24 in Android template

3 participants