Skip to content

Decide on a path to stop stripping libapp.so and libflutter.so by default for android builds #155576

Description

@gmackall

Context #60240.

We currently strip debug symbols when building the the AOT snapshot and when building the engine. This means that when Flutter developers build an appbundle (flutter build appbundle) these debug symbols are not available to the Android Gradle plugin (AGP), and therefore they obviously can't be included in the appbundle, which results in the warning in the play store that we see in the linked issue.

Since AGP 4.1, AGP itself can handle both stripping the debug symbols from the native code, and automatically including it in the appbundle in a way that is available to app stores, but does not get delivered to end users* (see https://support.google.com/googleplay/android-developer/answer/9848633#upload_file). So ideally, we could simply stop stripping these files when building for Android, and instead let AGP handle the debug symbols.

HOWEVER - the Flutter Gradle plugin has for some time now vended a recommended version of the NDK (flutter.ndkVersion) that we use to specify the ndkVersion property in apps gradle files, and importantly, if an app specifies an ndk version, and doesn't have that ndk version installed locally, the app will build but silently fail to strip the debug symbols, meaning that they end up in the final app (greatly inflating the app size).

So before we can stop stripping the debug symbols from these files by default, we need to decide on a path that ensures we don't create a foot gun where developers build, unaware that they don't have the ndk version they are specifying installed, and end up with unnecessarily large apps.

In my mind there are two main options, but other suggestions are welcome:

  1. Get rid of flutter.ndkVersion entirely via a migrator. If users don't specify an ndk version, apps will instead use the default version provided by AGP. This is option two in this section of the android docs - AGP will download the version by default. There is also a community issue suggesting we do this.
  2. Keep flutter.ndkVersion around, and instead modify the flutter tool/flutter doctor to ensure that we check/enforce that users have the version of the ndk that we specify installed.

* More specifically, the symbols get stripped and included in a BUNDLE-METADATA subdirectory of the app bundle format, see this comment for more details.

Activity

  1. AbdeMohlbi commented on Sep 23, 2024

    @AbdeMohlbi
    Member

    What does happen when some used plugins have a newer version then flutter.ndkversion inside gradle files ? Does the build fail in this case? No conflicts?

  2. added
    in triagePresently being triaged by the triage team
    platform-androidAndroid applications specifically
    toolAffects the "flutter" command-line tool. See also t: labels.
    c: proposalA detailed proposal for a change to Flutter
    a: buildBuilding flutter applications with the tool
    team-androidOwned by Android platform team
    and removed
    in triagePresently being triaged by the triage team
    on Sep 24, 2024
  3. added
    P1High-priority issues at the top of the work list
    triaged-androidTriaged by Android platform team
    on Sep 26, 2024
  4. gmackall commented on Oct 3, 2024

    @gmackall
    MemberAuthor

    Potentially, for 1, write a migrator that instead of removing the line, replaces flutter.ndkVersion with AGPs variable that holds their preferred ndk version, if such a variable exists

  5. Sameri11 commented on Oct 6, 2024

    @Sameri11
    Contributor

    I personally don't really like first option because, in my opinion, there should be 1 source of truth for things like that. At least because there are already warnings in android builds, alarming about different versions of NDK in plugins and app (example). Although I do not think that this warning is fixable only by specifying NDK version (it doesn't work already lol), I think that relying on standard AGP mechanism for NDK downloading is another step back from avoiding this kind of problems.

    Plus, I believe that another teams on a path of solving similar problem, for example #144530

    I think it would be create doctor validator and, to enforce, Gradle's warning for debug/profile and error for release builds respectfully, if there's no needed ndk version found.

  6. gmackall commented on Oct 22, 2024

    @gmackall
    MemberAuthor

    Still no decision has been made, but adding some more info that according to my local testing and some internal info, apparently AGP will automatically download the NDK for every use case except for when it is needed for stripping debug symbols from prebuilt libraries.

    So we can't rely on AGP to guarantee the availability of the NDK.

  7. AbdeMohlbi commented on Oct 23, 2024

    @AbdeMohlbi
    Member

    Still no decision has been made, but adding some more info that according to my local testing and some internal info, apparently AGP will automatically download the NDK for every use case except for when it is needed for stripping debug symbols from prebuilt libraries.

    So we can't rely on AGP to guarantee the availability of the NDK.

    If i recall correctly it's not that hard to know the ndk versions installed on a machine , the problem is it compatible ?
    for instance if u opened a fresh project and add sharedPrefernces or some other package when running the app it will prompt that this project require newer ndk version for exemple 27 and flutter.ndkVersion is 26 , so some users may find it kinda deceiving if flutter doctor would list that ndk is installed

  8. github-actions commented on Dec 27, 2024

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  9. locked as resolved and limited conversation to collaborators on Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work lista: buildBuilding flutter applications with the toolc: proposalA detailed proposal for a change to Flutterplatform-androidAndroid applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-androidOwned by Android platform teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-androidTriaged by Android platform team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions