Open HosseinYousefi opened 2 weeks ago
We need to support two flows:
flutter run --release
// flutter build
flutter assemble
We need to support two flows:
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.
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): ...
FlutterPlugin
(a Gradle plugin). 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.
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/
@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.
@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.
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: https://github.com/dart-lang/native/issues/681
@gmackall @reidbaker @dcharkes @mkustermann