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

AndroidView requires api level 23 or greater since Flutter 3.19 without any breaking change warnings #147210

Open
CoderBuck opened this issue Apr 23, 2024 · 6 comments · Fixed by flutter/website#10444
Assignees
Labels
a: platform-views Embedding Android/iOS views in Flutter apps engine flutter/engine repository. See also e: labels. P1 High-priority issues at the top of the work list platform-android Android applications specifically team-android Owned by Android platform team

Comments

@CoderBuck
Copy link

Steps to reproduce

After I upgraded Flutter sdk from 3.13 to 3.19 I started getting logs like this in runtime:

Platform views cannot be displayed below API level 23. You can prevent this issue by setting 'minSdkVersion: 23' in build.gradle.

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
image

after: throw error
image

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)

@CoderBuck CoderBuck changed the title AndroidView requires api level 23 or greater since Flutter 3.0 without any breaking change warnings AndroidView requires api level 23 or greater since Flutter 3.19 without any breaking change warnings Apr 23, 2024
@danagbemava-nc danagbemava-nc added in triage Presently being triaged by the triage team platform-android Android applications specifically a: platform-views Embedding Android/iOS views in Flutter apps team-android Owned by Android platform team engine flutter/engine repository. See also e: labels. and removed in triage Presently being triaged by the triage team labels Apr 23, 2024
@reidbaker reidbaker added the P1 High-priority issues at the top of the work list label Apr 23, 2024
@reidbaker
Copy link
Contributor

Thank you for the issue! FYI the likely resolution is modify documentation as opposed to modifying the behavior in code.

@reidbaker
Copy link
Contributor

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.

reidbaker added a commit to flutter/website that referenced this issue Apr 23, 2024
This has been the case since flutter 3.0 but did not appear to be documented. 

Related to flutter/flutter#147210
sfshaza2 pushed a commit to flutter/website that referenced this issue Apr 23, 2024
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.
@danagbemava-nc danagbemava-nc added the r: fixed Issue is closed as already fixed in a newer version label Apr 24, 2024
@stuartmorgan
Copy link
Contributor

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:

You correctly found the pr that turned the error from a silent error to an active one.

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.

@stuartmorgan stuartmorgan reopened this Apr 25, 2024
@stuartmorgan stuartmorgan removed the r: fixed Issue is closed as already fixed in a newer version label Apr 25, 2024
@reidbaker
Copy link
Contributor

@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.
https://github.com/flutter/flutter/wiki/Virtual-Display

@stuartmorgan
Copy link
Contributor

@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.

@CoderBuck
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: platform-views Embedding Android/iOS views in Flutter apps engine flutter/engine repository. See also e: labels. P1 High-priority issues at the top of the work list platform-android Android applications specifically team-android Owned by Android platform team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants