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

Skip to content

Flutter needs to declare abiFilters for only supported architectures by default #153476

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

Open
lukehutch opened this issue Aug 14, 2024 · 13 comments
Open
Assignees
Labels
c: proposal A detailed proposal for a change to Flutter P2 Important issues not at the top of the work list platform-android Android applications specifically team-android Owned by Android platform team tool Affects the "flutter" command-line tool. See also t: labels. triaged-android Triaged by Android platform team

Comments

@lukehutch
Copy link
Contributor

Steps to reproduce

Flutter does not set abiFilters in its default flutter create template, which means that without intervention, apps published to the Play Store all declare that they will run on x86 (x86_32), which is not (and never will be) supported by Flutter.

Users with x86 devices who install the app from Google Play will be met with a crash, which is logged in Crashlytics as java.lang.UnsatisfiedLinkError: dlopen failed: library "libflutter.so" not found.

This issue is forked from #151638 at the request of @danagbemava-nc, who said:

It appears there was an attempt to add this in #135529 but it was later reverted in #142089 and it must have dropped off everyone's radar. Can you file a new proposal for adding it?

Expected results

Flutter should opt-in to all of its supported architectures by default using ndk.abiFilters.

Actual results

Failing to set abiFilters means that the app can run on all architectures supported on Google Play, which simply does not reflect reality.

Code sample

Code sample

android/app/build.gradle should include something like this when flutter create is called:

android {
    defaultConfig {
        ndk.abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86_64'
    }
}

Screenshots or Video

N/A

Logs

N/A

Flutter Doctor output

Doctor output
$ flutter doctor -v
[✓] Flutter (Channel beta, 3.24.0-0.2.pre, on Fedora Linux 40 (Workstation Edition) 6.10.3-200.fc40.x86_64, locale en_US.utf8)
    • Flutter version 3.24.0-0.2.pre on channel beta at /opt/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 7c6b7e9ca4 (2 weeks ago), 2024-07-30 14:26:44 +0700
    • Engine revision 6e4deceb38
    • Dart version 3.5.0 (build 3.5.0-323.2.beta)
    • DevTools version 2.37.2

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /home/luke/Android/Sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /opt/android-studio/jbr/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • clang version 18.1.6 (Fedora 18.1.6-3.fc40)
    • cmake version 3.28.2
    • ninja version 1.12.1
    • pkg-config version 2.1.1

[✓] Android Studio (version 2023.3)
    • Android Studio at /opt/android-studio
    • Flutter plugin version 79.0.2
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)

[✓] VS Code (version 1.92.1)
    • VS Code at /usr/share/code
    • Flutter extension version 3.95.20240801

[✓] VS Code (version 1.93.0-insider)
    • VS Code at /usr/share/code-insiders
    • Flutter extension version 3.91.20240529

[✓] Connected device (2 available)
    • Linux (desktop) • linux  • linux-x64      • Fedora Linux 40 (Workstation Edition) 6.10.3-200.fc40.x86_64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 127.0.6533.119

[✓] Network resources
    • All expected network resources are available.

• No issues found!
@darshankawar darshankawar added the in triage Presently being triaged by the triage team label Aug 15, 2024
@darshankawar
Copy link
Member

Thanks for the report. Treating this as a proposal and labeling as applicable for team's attention.

Reverted PR: #142089

@darshankawar darshankawar added platform-android Android applications specifically tool Affects the "flutter" command-line tool. See also t: labels. c: proposal A detailed proposal for a change to Flutter team-tool Owned by Flutter Tool team and removed in triage Presently being triaged by the triage team labels Aug 15, 2024
@andrewkolos andrewkolos added team-android Owned by Android platform team and removed team-tool Owned by Flutter Tool team labels Aug 20, 2024
@andrewkolos
Copy link
Contributor

andrewkolos commented Aug 20, 2024

Punting to team-android since this looks related to #135173 (which was reverted) and they might have a better idea of what's going on here. Feel free to punt it back to team-tool if this is distinctly a flutter tool issue.

@gmackall
Copy link
Member

Punting to team-android since this looks related to #135173 (which was reverted) and they might have a better idea of what's going on here. Feel free to punt it back to team-tool if this is distinctly a flutter tool issue.

Huh, I was not aware this was reverted. Assigning to myself

@gmackall gmackall self-assigned this Aug 22, 2024
@gmackall gmackall added P2 Important issues not at the top of the work list triaged-android Triaged by Android platform team labels Aug 22, 2024
@Dooks123
Copy link

Dooks123 commented Sep 7, 2024

@gmackall I don't think adding the abiFilters will change anything. Look at my #151638 (comment). The "Native Platforms" on the Android App Bundle Details does in fact only show the mentioned 'armeabi-v7a', 'arm64-v8a', 'x86_64' without the abiFilters being added to this app gradle, so it is not like it is adding more abis which flutter doesn't have or support.

This looks more like an issue with Android App Bundles and Google Play itself and how it dishes out APKs to be installed on the different architectures. Or there might even be an issue on how it generates the different APKs from the AAB and referencing the wrong libflutter.so. I'm just speculating here.

@Dooks123
Copy link

Dooks123 commented Sep 7, 2024

@gmackall Have a look at my #151638 (comment). It is looking for libflutter.so in the wrong place.

Trying to load libflutter.so from .../lib/arm64 instead of .../lib/arm64-v8a which is the config.arm64_v8a.apk included by Google Play in the bundle for the device. Flutter or Google Play has it wrong.

@lukehutch
Copy link
Contributor Author

@Dooks123 this issue is specifically about preventing Flutter from declaring that it can't run on the unsupported x86 architecture.

(Nevertheless the path issue you pointed out is real, as covered in the other issue you linked.)

@Dooks123
Copy link

Dooks123 commented Sep 7, 2024

Interesting read about Android ABIs and to get a better understanding on how it works:
https://developer.android.com/ndk/guides/abis#am

But I think this is an Android App Bundle issue and Google Play only including the wrong abi for the device (not all devices, some - and might even differ every time you make a new release).

If you had an APK with all the ABIs - you'd have no problem at all.

@lukehutch
Copy link
Contributor Author

@Dooks123 again you are commenting on the wrong issue.

@flutter-triage-bot flutter-triage-bot bot added the Bot is counting down the days until it unassigns the issue label Dec 26, 2024
@flutter-triage-bot
Copy link

This issue is assigned to @gmackall but has had no recent status updates. Please consider unassigning this issue if it is not going to be addressed in the near future. This allows people to have a clearer picture of what work is actually planned. Thanks!

@lukehutch
Copy link
Contributor Author

@darshankawar What else needs to be done for triage on this bug? See also #151638, which is not the same but is related (many people have commented on that issue that they have hit the issue). That issue also needs to be looked at.

@darshankawar
Copy link
Member

@lukehutch This issue is already triaged and has P2 priority. Please see this for more context on priority labels.

@GeylanKalafMohe
Copy link

Any update please? I still face Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: "../app_lib/libflutter.so" is 32-bit instead of 64-bit even though i added ndk.abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86_64'

@Sameri11
Copy link
Contributor

Sameri11 commented May 4, 2025

Figured out that adding abiFilters hardcoded in the template (or in build.gradle.kts itself) will not work if --split-per-abi is used alongside --target-platform. It will cause an issue: if the ABIs added to the --target-platform argument are not the same as the ABIs in abiFilters, Gradle will fail the build with an error. For example, if --split-per-abi --target-platform=android-arm,android-arm64 is passed and abiFilters is "arm64-v8a", "x86_64", "armeabi-v7a", this error will happen:

Conflicting configuration : 'armeabi-v7a,arm64-v8a,x86_64' in ndk abiFilters cannot be present when splits abi filters are set : armeabi-v7a,arm64-v8a

I guess maybe abiFilters should not be hardcoded in templates, but instead added somewhere inside the Flutter Gradle Plugin based on options provided to the build. For example, add abiFilters only when there's no split-per-abiargument. But maybe the conditions are more complex.

Also, adding abiFilters to templates will break debug builds targeting android-x86 target: app will be built but will not contain libflutter.so which will lead to instant crashes. This will remain at least until #157543 is resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: proposal A detailed proposal for a change to Flutter P2 Important issues not at the top of the work list platform-android Android applications specifically team-android Owned by Android platform team tool Affects the "flutter" command-line tool. See also t: labels. triaged-android Triaged by Android platform team
Projects
None yet
Development

No branches or pull requests

7 participants