Skip to content

Inject proguard rules after Dart AOT compilation to gradle #154170

Open

Description

@HosseinYousefi

Once the Dart code is compiled in AOT mode, we can understand which methods and classes are used from the jnigen generated bindings and can use that to generate proguard rules. The tree-shaking information is accessible through hook/link.dart.

I'm not sure how the release build pipeline looks like, for example if the process starts with gradle can we then inject the generated proguard rules mid build?

Context: dart-lang/native#681

@gmackall @reidbaker @dcharkes @mkustermann

Activity

  1. changed the title [-]Inject proguard rules[/-] [+]Inject proguard rules after Dart AOT compilation to gradle[/+] on Aug 27, 2024
  2. added
    a: buildBuilding flutter applications with the tool
    toolAffects the "flutter" command-line tool. See also t: labels.
    t: gradle"flutter build" and "flutter run" on Android
    team-androidOwned by Android platform team
    on Aug 27, 2024
  3. dcharkes commented on Aug 27, 2024

    @dcharkes
    Contributor

    We need to support two flows:

    • flutter run --release // flutter build
      • gradle build
        • flutter assemble

    We need to support two flows:

    • gradle build (run or release from Android Studio)
      • flutter assemble

    So that means that we only know about the proguard rules halfway during the Gradle build. (Flutter assemble invokes the build and link hooks in the native assets target: lib/src/build_system/targets/native_assets.dart)

    I'm not sure how the release build pipeline looks like, for example if the process starts with gradle can we then inject the generated proguard rules mid build?

    I don't know much about Gradle.

  4. gmackall commented on Aug 27, 2024

    @gmackall
    Member

    I'm not sure how the release build pipeline looks like, for example if the process starts with gradle can we then inject the generated proguard rules mid build?

    Yes, I believe this should be possible.

    The current general ordering of steps is (with more before and after):
    ...

    1. The Flutter tool invokes Gradle.
    2. Gradle invokes our FlutterPlugin (a Gradle plugin).
    3. Our FlutterPlugin invokes the Flutter tool again.
      ...

    See the somewhat outdated go/flutter-build-android-app-lifecycle (flutter.gradle -> flutter.groovy).

    Also, we currently configure proguard rules here, as a breadcrumb.

  5. reidbaker commented on Aug 27, 2024

    @reidbaker
    Member

    I would add that google/android has a default proguard file that is included as part of AGP.
    https://www.zacsweers.dev/android-proguard-rules/

  6. reidbaker commented on Sep 5, 2024

    @reidbaker
    Member

    @HosseinYousefi what parts of this feature are you wanting team-android to do? @gmackall mentioned in triage that this is likely tracking work you are actively doing.

  7. HosseinYousefi commented on Sep 5, 2024

    @HosseinYousefi
    ContributorAuthor

    @HosseinYousefi what parts of this feature are you wanting team-android to do? @gmackall mentioned in triage that this is likely tracking work you are actively doing.

    I'm currently working on #154165. I'll work on this next. I'll reach out to y'all if I had problems.

  8. added
    ⏳Bot is counting down the days until it unassigns the issue
    on Jan 15, 2026
  9. flutter-triage-bot commented on Jan 15, 2026

    @flutter-triage-bot

    This issue is assigned to @HosseinYousefi 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!

  10. mkustermann commented on Jan 15, 2026

    @mkustermann
    Member

    /cc @goderbauer Maybe you can find a new owner for this?

  11. removed
    ⏳Bot is counting down the days until it unassigns the issue
    on Jan 15, 2026
  12. added
    ⏳Bot is counting down the days until it unassigns the issue
    on May 21, 2026
  13. flutter-triage-bot commented on May 21, 2026

    @flutter-triage-bot

    This issue is assigned to @liamappelbe 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!

  14. flutter-triage-bot commented on Aug 6, 2026

    @flutter-triage-bot

    This issue was assigned to @liamappelbe but has had no status updates in a long time. To remove any ambiguity about whether the issue is being worked on, the assignee was removed.

  15. removed
    ⏳Bot is counting down the days until it unassigns the issue
    on Aug 6, 2026
  16. gmackall commented on Aug 11, 2026

    @gmackall
    Member

    From android triage: cc @goderbauer and @liamappelbe
    should this find a new owner? Or should we swap labels off of the android team?

  17. added
    P2Important issues not at the top of the work list
    triaged-androidTriaged by Android platform team
    on Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: buildBuilding flutter applications with the toolc: new featureNothing broken; request for a new capabilityp: toolingAffects the flutter_plugin_tools packaget: gradle"flutter build" and "flutter run" on Androidteam-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