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
Make MAUI blazor which required android api 24 compatible to api 21 #8375
Conversation
[SupportedOSPlatform("android23.0")] | ||
[SupportedOSPlatform("android21.0")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove these attributes now since we have a min version in .NET itself that is 21. .NET 6 does not run on lower than 21.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed
@@ -108,6 +109,7 @@ public override void OnMessage(WebMessagePort? port, WebMessage? message) | |||
|
|||
_onMessageReceived(message.Data); | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: extra line
@wch1618 would you mind filing an issue first explaining the motivation for the change as well as the impact so that the team can assess whether or not we want to take this change in? |
Agreed with @javiercn It would also be great to hear from someone on the MAUI team who has worked on Android support (and perhaps added the existing AndroidX references), cc @jonathanpeppers @jpobst:
If it's safe and doesn't impact perf/stability/etc., then it's certainly an advantage to get support for a wider range of devices! Hope that's OK - we on the Blazor team don't have as much experience as some others in MAUI about the lower-level details of Android support. |
<PackageReference | ||
Update="Xamarin.AndroidX.WebKit" | ||
Version="1.4.0.8" | ||
/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is an Update
, how does this line do anything? It must already be a transitive dependency, and we can remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@javiercn would you mind filing an issue first explaining the motivation for the change as well as the impact so that the team can assess whether or not we want to take this change in?
Please forgive me for not having time to reply a few days ago.
This is not necessary, but just a suggestion for the following reasons.
-
From Android API 24 to 23, it is not difficult for Android. They are all official.
-
API 21 app will run on approximately 98.6% of devices, and API 24 app only has 91.7%. The is from Android studio.
-
Using androidx.webkit increases the size of Android installation package a little and the performance loss is almost negligible.
-
It makes the Android device compatibility of Maui Blazor consistent with Maui.
-
My test method is temporarily modified the namespace of Microsoft.AspNetCore.Components.WebView.Maui.csproj and only compile it with min Android API 21, so that it can be directly added to the Maui blazor app project, and then tested on the real machine of Android 5(API 21). The startup speed is acceptable, which is 40% faster than blazor WebAssembly. This is stupid, but simple and effective.
The AndroidX libraries are a "polyfill" for making your app run on old Android versions. I would recommend using this for BlazorWebView if things break on API 21. Does someone know what the actual problem is? It's common for Android to add something new, so I wouldn't be surprised if some method is used that was introduced in 23. However, to know if this PR is going to work, I would have someone manually test this change on Android emulators of different versions. |
I see, this was introduced in API 23: |
/azp run |
Azure Pipelines successfully started running 2 pipeline(s). |
We'll also need to update the min Android API version in the Maui blazor csproj, project template (#7342) |
Yeah, Blazor is only supported on Android API 23+ but the rest of MAUI and .NET support API 21+. |
Current error:
Did this compile locally? |
We probably also need to enable device tests on the older platforms too: https://github.com/dotnet/maui/blob/main/eng/pipelines/device-tests.yml#L110 |
As for the reply to the failure of the test, I only modified the platform code related to Android, which has nothing to do with MacOS and windows. I have tried to check the details of the test error to see whether it can be handled, but unfortunately, the details did not describe not clearly enough. Other small problems, such as redundant lines and redundant attributes, please help remove them. |
Description of Change
Using androidx.webkit.WebViewCompat to make AndroidWebKitWebViewManager from android api 23 compatible to api 21 or more low.