-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[Android] add abiFilters to Flutter Gradle Plugin #168293
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
339f273
to
3645c87
Compare
0a18e48
to
eaae72e
Compare
9525cba
to
4d80540
Compare
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.
LGTM, great find in #153476 (comment)!
I had suspected that abifilters were not necessary for the same reason you mentioned (that the FGP only packages the 3 ABIs it works on by default), but had not considered that the inclusion of a different native library could cause an x86
variant to get included.
packages/flutter_tools/test/integration.shard/gradle_jni_packaging_test.dart
Outdated
Show resolved
Hide resolved
packages/flutter_tools/test/integration.shard/gradle_jni_packaging_test.dart
Show resolved
Hide resolved
00b8ab6
to
2e82307
Compare
Google testing seems to just not work w/ changes to the FGP, I'll override the failure. |
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.
Thank you so much for this pr! This is a tricky issue and I like the root cause work you did.
} | ||
} else { | ||
FlutterPluginUtils.getAndroidExtension(project).buildTypes.forEach { buildType -> | ||
if (!buildType.isDebuggable) { |
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.
I think this would run for flutter add to app projects. In add to app we have allow developers to possibly ship flutter on architectures that flutter does not support because they can control when flutter is run.
Please modify this if statement to only run if the project is a normal full flutter app.
I think that could be done by using FlutterPluginUtils.isFlutterAppProject
. (and a test)
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.
Wow, it's gonna take couple days for me to refresh knowledge about a2a and figure out test strategy. But I think just FlutterPluginUtils.isFlutterAppProject
is not sufficient here because it just checks AGP's app extension exists, and in this case a2a project where flutter module added as source code dependency still might be affected.
Anyway, I'll figure out something, will keep you posted :)
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.
Or maybe I'm wrong thinking that FGP applied to a2a project with sources dependency 🤔 Anyway, as I said, I'm going to need some time.
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.
@reidbaker Hi again!
I played a little with add-to-app and here what I found:
- For
flutter build aar
,abiFilters
does nothing, becauseliblfutter.so
is not packaged toaar
artefacts, they only being added as dependencies topom
files. So change from this PR does not affect this case. - When flutter module added as a project dependency (
implementation(project(":flutter"))
), FGP is not applied to the mainapp
subproject, soapply
is not called at all – this case is also not affected by this PR.
I mean, adding this condition might be semantically justified, say, we want emphasize that only app-building case affected. But in that case it might be hard to test this, because there won't be case where abiFilters
is actually affects packaging.
So, I do not see any case where this change might affect a-2-a scenario. Only question is, what do I miss here? :)
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.
Thank you for that research. Can you add a comment that helps explain that logic here?
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.
Indeed :) I've added a comment. Let me know if it's too excessive. And thanks for review!
6c08273
to
6589fc8
Compare
6589fc8
to
c00fe39
Compare
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.
Approve % comment explaining what the code being added does in plain english and why it does not impact add to app.
3a32030
to
6a95b50
Compare
fixes flutter#153476 More context in flutter#153476 (comment) and flutter#153476 (comment) TLDR: `abiFilters` cannot be added to templates (the original issue proposes that) because it will break the Gradle build if the `--splits-per-abi` option is provided: ``` Conflicting configuration : 'armeabi-v7a,arm64-v8a,x86_64' in ndk abiFilters cannot be present when splits abi filters are set : armeabi-v7a,arm64-v8a ``` In this PR, `abiFilters` is added programmatically in the Flutter Gradle Plugin when the `splits-per-abi` option is not provided and only for non-debuggable builds. As stated in flutter#153476 (comment), `abiFilters` are actually useful in cases when a third-party dependency is used with the `x86` variant. In other cases (such as a fresh Flutter app project), `abiFilters` are a bit excessive, but they do no harm. <!-- Thanks for filing a pull request! Reviewers are typically assigned within a week of filing a request. To learn more about code review, see our documentation on Tree Hygiene: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md --> ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
_Description of what this PR is changing or adding, and why:_ Adds a breaking change for flutter/flutter#168293 which landed in 3.35. TLDR: To set custom Android ABI filters, you must clear the defaults that Flutter sets or use the Flutter-provided flag for doing so. _Issues fixed by this PR (if any):_ Fixes flutter/flutter#174004 _PRs or commits this PR depends on (if any):_ N/A ## Presubmit checklist - [ ] If you are unwilling, or unable, to sign the CLA, even for a _tiny_, one-word PR, please file an issue instead of a PR. - [ ] If this PR is not meant to land until a future stable release, mark it as draft with an explanation. - [ ] 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 pronouns). - [ ] 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. --------- Co-authored-by: Shams Zakhour <[email protected]> Co-authored-by: Gray Mackall <[email protected]>
fixes #153476
More context in #153476 (comment) and #153476 (comment)
TLDR:
abiFilters
cannot be added to templates (the original issue proposes that) because it will break the Gradle build if the--splits-per-abi
option is provided:In this PR,
abiFilters
is added programmatically in the Flutter Gradle Plugin when thesplits-per-abi
option is not provided and only for non-debuggable builds.As stated in #153476 (comment),
abiFilters
are actually useful in cases when a third-party dependency is used with thex86
variant. In other cases (such as a fresh Flutter app project),abiFilters
are a bit excessive, but they do no harm.Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.