Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

Sameri11
Copy link
Contributor

@Sameri11 Sameri11 commented May 4, 2025

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:

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

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@github-actions github-actions bot added the tool Affects the "flutter" command-line tool. See also t: labels. label May 4, 2025
@Sameri11 Sameri11 force-pushed the android-ndk-abi-filters branch from 339f273 to 3645c87 Compare May 11, 2025 16:15
@github-actions github-actions bot added the platform-android Android applications specifically label May 11, 2025
@Sameri11 Sameri11 force-pushed the android-ndk-abi-filters branch 3 times, most recently from 0a18e48 to eaae72e Compare May 14, 2025 06:00
@Sameri11 Sameri11 changed the title [Android] add abiFilters to app templates [Android] add abiFilters to Flutter Gradle Plugin May 15, 2025
@Sameri11 Sameri11 force-pushed the android-ndk-abi-filters branch 3 times, most recently from 9525cba to 4d80540 Compare May 16, 2025 06:07
@Sameri11 Sameri11 marked this pull request as ready for review May 16, 2025 08:50
Copy link
Member

@gmackall gmackall left a 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.

@Sameri11 Sameri11 force-pushed the android-ndk-abi-filters branch 2 times, most recently from 00b8ab6 to 2e82307 Compare May 20, 2025 18:27
@gmackall
Copy link
Member

Google testing seems to just not work w/ changes to the FGP, I'll override the failure.

Copy link
Contributor

@reidbaker reidbaker left a 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) {
Copy link
Contributor

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)

Copy link
Contributor Author

@Sameri11 Sameri11 Jun 1, 2025

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 :)

Copy link
Contributor Author

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.

Copy link
Contributor Author

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:

  1. For flutter build aar, abiFilters does nothing, because liblfutter.so is not packaged to aar artefacts, they only being added as dependencies to pom files. So change from this PR does not affect this case.
  2. When flutter module added as a project dependency (implementation(project(":flutter"))), FGP is not applied to the main app subproject, so apply 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? :)

Copy link
Contributor

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?

Copy link
Contributor Author

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!

@Sameri11 Sameri11 force-pushed the android-ndk-abi-filters branch 2 times, most recently from 6c08273 to 6589fc8 Compare June 5, 2025 18:11
@Sameri11 Sameri11 requested a review from reidbaker June 5, 2025 18:12
@Sameri11 Sameri11 force-pushed the android-ndk-abi-filters branch from 6589fc8 to c00fe39 Compare June 5, 2025 18:31
Copy link
Contributor

@reidbaker reidbaker left a 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.

@Sameri11 Sameri11 force-pushed the android-ndk-abi-filters branch 3 times, most recently from 3a32030 to 6a95b50 Compare June 14, 2025 12:51
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 17, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 17, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 18, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 18, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 18, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 18, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 18, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 18, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 18, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 19, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 19, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 19, 2025
mboetger pushed a commit to mboetger/flutter that referenced this pull request Jul 21, 2025
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
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 15, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 15, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 16, 2025
camsim99 added a commit to flutter/website that referenced this pull request Aug 26, 2025
_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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform-android Android applications specifically tool Affects the "flutter" command-line tool. See also t: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Flutter needs to declare abiFilters for only supported architectures by default
3 participants