-
Notifications
You must be signed in to change notification settings - Fork 559
[Xamarin.Android.Build.Tasks] require JDK 11 for API 31 #6084
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
Conversation
7696554
to
0742ad9
Compare
We're starting to wonder if we properly understand what's going on here. The current PR build, which requires JDK 11 for API-31+, has lots of unit test failures, most of which are because of the new check, e.g. LatestTFV_OldTargetSdkVersion:
These tests are currently building now, meaning most of our tests are currently able to target v11.0.99 ("API-S") and build. They're building now, without incurring the There's something important that we're not understanding here. :-( More investigation is required. |
The tests that fail in #6094 are Xamarin.Forms 4.0 apps that use Android Support libraries. So I tried doing a Blank Android App in VS 2022, then changed The problem went away when I removed all AndroidX packages. So perhaps, the presence of Android Support or AndroidX causes the issue? Many of our tests just use plain Android. |
0742ad9
to
4df4758
Compare
95e8eec
to
2deaad5
Compare
Ugh, need to fix the conflict |
API 31 builds fail when using JDK 1.8 with: /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1728,3): error JAVAC0000: java.lang.AssertionError: annotationType() : unrecognized Attribute name MODULE (class com.sun.tools.javac.util.SharedNameTable$NameImpl) To solve this issue, we must require JDK 11 for API 31. There are two code paths here for "legacy" Xamarin.Android and .NET 6. Legacy is straightforward, as we already had a pattern for this. In .NET 6, I checked the `$(TargetPlatformVersion)` property for now and require JDK 11 in that case. When API 31 is stable, we can probably remove this code and just set this value by default: <MinimumSupportedJavaVersion Condition=" '$(MinimumSupportedJavaVersion)' == '' ">11.0</MinimumSupportedJavaVersion> * Add new `AssertTargetFrameworkVersionSupported()` method In tests where it makes sense, I used a different `$(TargetFrameworkVersion)` or just removed what was setting the property entirely. Other tests, I used a `AssertTargetFrameworkVersionSupported()` method to `Assert.Ignore()` the test if it would not pass otherwise.
2deaad5
to
3baf253
Compare
API-31 builds fail when using JDK 1.8 and using AndroidX with:
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1728,3):
error JAVAC0000: java.lang.AssertionError: annotationType() : unrecognized Attribute name MODULE (class com.sun.tools.javac.util.SharedNameTable$NameImpl)
There are two plausible solutions to better handle this:
1. Only require JDK 11 when API-31 and AndroidX are being used, or
2. Always required JDK 11 for API-31+
As we believe *most* apps will be using AndroidX, there is little
point to attempting so support (1); (2) it is!
We must require JDK 11 for API-31+.
There are two code paths here: one for "legacy" Xamarin.Android, and
one for .NET 6.
Legacy is straightforward, as we already had a pattern for this, we
just update the `<ValidateJavaVersion/>` task.
For .NET 6, I checked the `$(TargetPlatformVersion)` property for now
and require JDK 11 in that case. When API-31 is stable, we can
probably remove this code and just set this value by default:
<MinimumSupportedJavaVersion Condition=" '$(MinimumSupportedJavaVersion)' == '' ">11.0</MinimumSupportedJavaVersion>
For our unit tests -- most of which would be solution (1) (API-31
and *no* AndroidX use), but many of which started to fail because we
went with solution (2) -- we did one of two things:
1. Use a different `$(TargetFrameworkVersion)` and/or remove
`$(TargetFrameworkVersion)` entirely, or
2. Use a new `BuildTest.AssertTargetFrameworkVersionSupported()`
method which `Assert.Ignore()`s the test if it would not
pass otherwise. |
API-31 builds fail when using JDK 1.8 and using AndroidX with: /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1728,3): error JAVAC0000: java.lang.AssertionError: annotationType() : unrecognized Attribute name MODULE (class com.sun.tools.javac.util.SharedNameTable$NameImpl) There are two plausible solutions to better handle this: 1. Only require JDK 11 when API-31 and AndroidX are being used, or 2. Always required JDK 11 for API-31+ As we believe *most* apps will be using AndroidX, there is little point to attempting so support (1); (2) it is! We must require JDK 11 for API-31+. There are two code paths here: one for "legacy" Xamarin.Android, and one for .NET 6. Legacy is straightforward, as we already had a pattern for this, we just update the `<ValidateJavaVersion/>` task. For .NET 6, I checked the `$(TargetPlatformVersion)` property for now and require JDK 11 in that case. When API-31 is stable, we can probably remove this code and just set this value by default: <MinimumSupportedJavaVersion Condition=" '$(MinimumSupportedJavaVersion)' == '' ">11.0</MinimumSupportedJavaVersion> For our unit tests -- most of which would be solution (1) (API-31 and *no* AndroidX use), but many of which started to fail because we went with solution (2) -- we did one of two things: 1. Use a different `$(TargetFrameworkVersion)` and/or remove `$(TargetFrameworkVersion)` entirely, or 2. Use a new `BuildTest.AssertTargetFrameworkVersionSupported()` method which `Assert.Ignore()`s the test if it would not pass otherwise.
API-31 builds fail when using JDK 1.8 and using AndroidX with: /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1728,3): error JAVAC0000: java.lang.AssertionError: annotationType() : unrecognized Attribute name MODULE (class com.sun.tools.javac.util.SharedNameTable$NameImpl) There are two plausible solutions to better handle this: 1. Only require JDK 11 when API-31 and AndroidX are being used, or 2. Always required JDK 11 for API-31+ As we believe *most* apps will be using AndroidX, there is little point to attempting so support (1); (2) it is! We must require JDK 11 for API-31+. There are two code paths here: one for "legacy" Xamarin.Android, and one for .NET 6. Legacy is straightforward, as we already had a pattern for this, we just update the `<ValidateJavaVersion/>` task. For .NET 6, I checked the `$(TargetPlatformVersion)` property for now and require JDK 11 in that case. When API-31 is stable, we can probably remove this code and just set this value by default: <MinimumSupportedJavaVersion Condition=" '$(MinimumSupportedJavaVersion)' == '' ">11.0</MinimumSupportedJavaVersion> For our unit tests -- most of which would be solution (1) (API-31 and *no* AndroidX use), but many of which started to fail because we went with solution (2) -- we did one of two things: 1. Use a different `$(TargetFrameworkVersion)` and/or remove `$(TargetFrameworkVersion)` entirely, or 2. Use a new `BuildTest.AssertTargetFrameworkVersionSupported()` method which `Assert.Ignore()`s the test if it would not pass otherwise.
API 31 builds fail when using JDK 1.8 with:
To solve this issue, we must require JDK 11 for API 31.
There are two code paths here for "legacy" Xamarin.Android and .NET 6.
Legacy is straightforward, as we already had a pattern for this.
In .NET 6, I checked the
$(TargetPlatformVersion)
property for nowand require JDK 11 in that case. When API 31 is stable, we can
probably remove this code and just set this value by default:
I updated some tests in this area as well.