Repository navigation
Description
The Flutter Gradle plugin is (by necessity) built on top of AGP.
AGP today has exposed APIs designed for extending it https://developer.android.com/build/extend-agp#variant-api-artifacts-tasks.
This was not the case when the Flutter Gradle plugin was written. Instead, we discovered tasks that AGP added by guessing their name as a string and then doing things with them (typically making them depend on the Flutter tasks that we were adding). We should remove this string based guessing, and migrate to their intended API.
e.g.
flutter/packages/flutter_tools/gradle/src/main/groovy/flutter.groovy
Lines 474 to 485 in e971379
| Task packageAssets | |
| Task cleanPackageAssets | |
| try { | |
| packageAssets = project.tasks.named("package${variant.name.capitalize()}Assets").get() | |
| } catch (UnknownTaskException ignored) { | |
| packageAssets = null | |
| } | |
| try { | |
| cleanPackageAssets = project.tasks.named("cleanPackage${variant.name.capitalize()}Assets").get() | |
| } catch (UnknownTaskException ignored) { | |
| cleanPackageAssets = null | |
| } |
The good news is that I think these attempts to get tasks might already be failing? They seemed to be always null in my brief testing, which means it would be easy to remove them. But that is a guess.
Activity
gmackall commentedon Apr 3, 2025
Making a full list
Tasks that I believe AGP names (but am unsure)
flutter/packages/flutter_tools/gradle/src/main/groovy/flutter.groovy
Lines 474 to 485 in e971379
flutter/packages/flutter_tools/gradle/src/main/groovy/flutter.groovy
Lines 603 to 607 in e971379
Tasks that I believe WE have named (but am unsure - but if correct we could move to a typesafe approach easily)
flutter/packages/flutter_tools/gradle/aar_init_script.gradle
Lines 183 to 187 in ceec33f
gmackall commentedon Apr 3, 2025
More generally speaking, it is a common pattern that Gradle will let you get something (a task, an extension, etc)
We should probably generally speaking stop using (1). In Groovy we would sometimes get something by string, and then because Groovy is dynamic we would just call a method that we hoped would exist (without casting). In Kotlin we can't do that, and we probably shouldn't have been doing that anyways. We should just get it in a typesafe way so that we know the methods/fields, and then call them accordingly.
reidbaker commentedon Apr 8, 2025
This will go to new a team member when they start next week and I know their github handle.
Fix warnings in FGP (#166727)
Fix warnings in FGP (flutter#166727)
flutter-triage-bot commentedon Aug 25, 2025
This issue is assigned to @mboetger 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!
Increase testing coverage and maintainability of android manifest par…
99 remaining items
[AGP 9.1.0 Migration flutter#7] Migrate the flutter-apk copy and per-…
[AGP 9.1.0 Migration flutter#8] Unify add-to-app module wiring on the…
[AGP 9.1.0 Migration flutter#9] Move aar_init_script to public AGP AP…
build: 切 AGP 内置 Kotlin + 升到 AGP 9.4.1 / Gradle 9.8.2
build: 按 AGP 建议抑制 newDsl / legacy variant API 警告
[Gradle] Run DependencyVersionChecker before accessing Android DSL ex…
Remove usesUnsupportedDependencyVersions extra property from Dependen…
Problem(deps): Flutter warns that this project's Gradle, AGP and Kotl…
[AGP 9.1.0 Migration flutter#6] Deliver Flutter assets as a generated…
[AGP 9.1.0 Migration flutter#7] Migrate the flutter-apk copy and per-…
[AGP 9.1.0 Migration flutter#8] Unify add-to-app module wiring on the…
[AGP 9.1.0 Migration flutter#9] Move aar_init_script to public AGP AP…
[Gradle] Run DependencyVersionChecker before accessing Android DSL ex…
Remove usesUnsupportedDependencyVersions extra property from Dependen…
[CP-beta][AGP 9.1.0 Migration #9] Move aar_init_script to public AGP …