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
AndroidView requires api level 23 or greater since Flutter 3.19 without any breaking change warnings #147210
Comments
Thank you for the issue! FYI the likely resolution is modify documentation as opposed to modifying the behavior in code. |
Platform views have required api 23 minimum api level since at least flutter 3.0. You correctly found the pr that turned the error from a silent error to an active one. If you don't wish to bump your min sdk to 23 and your users do not need your platform view you can either check the android api level before showing your platform view or catch the exception and swallow it and let the existing broken experience for users on api 21-22 continue. |
This has been the case since flutter 3.0 but did not appear to be documented. Related to flutter/flutter#147210
This has been the case since flutter 3.0 but did not appear to be documented. Related to flutter/flutter#147210 ## Presubmit checklist - [x] This PR doesn’t contain automatically generated corrections (Grammarly or similar). - [x] This PR follows the [Google Developer Documentation Style Guidelines](https://developers.google.com/style) — for example, it doesn’t use _i.e._ or _e.g._, and it avoids _I_ and _we_ (first person). - [x] This PR uses [semantic line breaks](https://github.com/dart-lang/site-shared/blob/main/doc/writing-for-dart-and-flutter-websites.md#semantic-line-breaks) of 80 characters or fewer.
Re-opening based on offline conversation; as far as @reidbaker and I could determine in our discussion the requirement of 23 was an accidental regression, not intentional behavior. This:
was based on what the error message said, but that message was actually wrong (for complicated historical reasons relating to how TLHC was introduced). Only TLHC required 23 (this logic is the high-level control for that switch), and I strongly suspect—though haven't validated via code tracing—that the incorrect error message was on a codepath downstream of the TLHC-or-not check, so was just not reached on pre-23 versions, and that the PR linked earlier in this issue accidentally moved it into the main code stream. |
@CoderBuck on my drive home from work I thought of a potential work around. Can you check to see if you explicitly enable virtualDisplay if platform views work for you on api 22 and below. |
@reidbaker I can't think of a way to force VD that would go through an codepath other than the one I linked to that will already switch to VD for <23. |
I confirmed again with an Android 5.1 phone that using PlatformView with Flutter 3.13.6 displays correctly, but with Flutter 3.19.5, it throws an error. Forcing the use of VD seems quite complex, right? From what I've read in the documentation, it seems like you need to fill a SurfaceView. I haven't tried this yet. Finally, due to this issue and the fact that we have very few users with Android SDK below 23, we have set minsdk to 23. |
Steps to reproduce
After I upgraded Flutter sdk from 3.13 to 3.19 I started getting logs like this in runtime:
Expected results
Min supported api level should not be incremented without any warnings in release notes.
Actual results
I didn't find any mentions of it in release notes. Nor how to handle it besides incrementing min api level.
It's a major breaking change and in our case we need to use platform views but have to stay with min api 21.
related issue: #105882
maybe related PR: flutter/engine#43813
before: only log error
after: throw error
Code sample
no
Screenshots or Video
No response
Logs
No response
Flutter Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.19.5, on macOS 12.7.4 21H1123 darwin-x64, locale zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 14.0.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.2)
[✓] IntelliJ IDEA Ultimate Edition (version 2023.3.6)
[✓] IntelliJ IDEA Community Edition (version 2023.2.5)
[✓] VS Code (version 1.78.2)
The text was updated successfully, but these errors were encountered: