Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jpobst
Copy link
Contributor

@jpobst jpobst commented Jan 7, 2025

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
Copy link
Contributor Author

jpobst commented Jan 8, 2025

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
Copy link
Member

@jonathanpeppers jonathanpeppers left a comment

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
Copy link
Member

jonpryor commented Jan 9, 2025

@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
Copy link
Contributor Author

jpobst commented Jan 9, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Set $(SupportedOSPlatformVersion)=24 in Android template
3 participants