Skip to content

Unify add-to-app module wiring on the variant API and drop host-project cross-wiring - #8

Open
reidbaker-agent wants to merge 1 commit into
agp-apk-copy-versioncodefrom
agp-add-to-app
Open

Unify add-to-app module wiring on the variant API and drop host-project cross-wiring#8
reidbaker-agent wants to merge 1 commit into
agp-apk-copy-versioncodefrom
agp-add-to-app

Conversation

@reidbaker-agent

@reidbaker-agent reidbaker-agent commented Jul 22, 2026

Copy link
Copy Markdown
Owner

Phase 8 of 11 of the AGP public-API migration; stacked on #7.

Phase P7 of the AGP public-API migration (flutter#180137,
flutter#166550), the last Kotlin consumer of the legacy variant
API:

  • Add-to-app module (library) projects now use the same consolidated
    onVariants block as application projects: the Flutter compile task
    and CopyFlutterAssetsTask are registered lazily per library variant,
    and flutter_assets are wired through
    variant.sources.assets.addGeneratedSourceDirectory. The host
    application consumes them through AGP's normal library packaging and
    variant matching, with build modes resolved from the public
    Component.debuggable flag (so a custom debuggable host build type
    such as 'staging' still maps to the debug engine artifacts via the
    module's matched variant). Module variants skip the CLI task-name
    gating: which module variant a host build consumes is AGP's variant
    matching decision, and a module has at most three variants to
    configure lazily.
  • The host-project lookup, the appProject.afterEvaluate
    libraryVariants.all x applicationVariants.all cross-product, the
    explicit merge<HostVariant>Assets.dependsOn edge, and the
    addFlutterDepsForModule legacy fork from P5 are deleted.
  • flutter.hostAppProjectName is now a no-op: it only fed the host
    lookup. A warning explains that it has no effect and will be removed
    in a future Flutter release.
  • The legacy com.android.builder.model.BuildType buildModeFor overload
    lost its last caller and is deleted along with its duplicate tests
    (the P2 name/debuggable and DSL overload tests cover the semantics).
    FlutterPlugin.kt and FlutterPluginUtils.kt no longer import any
    legacy (non com.android.build.api) AGP types.

Verification (CI): build_android_host_app_with_module_source,
module_host_with_custom_build, module_custom_host_app_name scenarios;
module-root flutter build apk; add-to-app newDsl=true test; gradle unit
tests on both AGP axes.

Revert-safe until P10 lands (mutually tolerant with P6).

CI must run the FGP unit tests (the Kotlin suite in packages/flutter_tools/gradle could not run in the delivery sandbox: dl.google.com returns 403, so AGP artifacts do not resolve).

@reidbaker-agent
reidbaker-agent force-pushed the agp-apk-copy-versioncode branch from c051ed0 to 1d44353 Compare July 22, 2026 15:54
@reidbaker-agent
reidbaker-agent force-pushed the agp-apk-copy-versioncode branch from 1d44353 to f3d2a31 Compare July 28, 2026 13:36
@reidbaker-agent
reidbaker-agent force-pushed the agp-apk-copy-versioncode branch from f3d2a31 to 91f0814 Compare July 28, 2026 13:37
@reidbaker-agent
reidbaker-agent force-pushed the agp-apk-copy-versioncode branch from 91f0814 to 45e5dea Compare July 29, 2026 20:21
@reidbaker-agent
reidbaker-agent force-pushed the agp-apk-copy-versioncode branch from 45e5dea to 9ce1623 Compare July 29, 2026 20:43
@reidbaker-agent
reidbaker-agent force-pushed the agp-apk-copy-versioncode branch from 9ce1623 to e34a92a Compare July 30, 2026 21:59
@reidbaker-agent
reidbaker-agent force-pushed the agp-apk-copy-versioncode branch from e34a92a to b7a23f7 Compare July 31, 2026 16:16
@reidbaker
reidbaker force-pushed the agp-apk-copy-versioncode branch from b7a23f7 to 53bcc7f Compare July 31, 2026 18:07
…ct cross-wiring

Phase P7 of the AGP public-API migration (flutter#180137,
flutter#166550), the last Kotlin consumer of the legacy variant
API:

- Add-to-app module (library) projects now use the same consolidated
  onVariants block as application projects: the Flutter compile task
  and CopyFlutterAssetsTask are registered lazily per library variant,
  and flutter_assets are wired through
  variant.sources.assets.addGeneratedSourceDirectory. The host
  application consumes them through AGP's normal library packaging and
  variant matching, with build modes resolved from the public
  Component.debuggable flag (so a custom debuggable host build type
  such as 'staging' still maps to the debug engine artifacts via the
  module's matched variant). Module variants skip the CLI task-name
  gating: which module variant a host build consumes is AGP's variant
  matching decision, and a module has at most three variants to
  configure lazily.
- The host-project lookup, the appProject.afterEvaluate
  libraryVariants.all x applicationVariants.all cross-product, the
  explicit merge<HostVariant>Assets.dependsOn edge, and the
  addFlutterDepsForModule legacy fork from P5 are deleted.
- flutter.hostAppProjectName is now a no-op: it only fed the host
  lookup. A warning explains that it has no effect and will be removed
  in a future Flutter release.
- The legacy com.android.builder.model.BuildType buildModeFor overload
  lost its last caller and is deleted along with its duplicate tests
  (the P2 name/debuggable and DSL overload tests cover the semantics).
  FlutterPlugin.kt and FlutterPluginUtils.kt no longer import any
  legacy (non com.android.build.api) AGP types.

Verification (CI): build_android_host_app_with_module_source,
module_host_with_custom_build, module_custom_host_app_name scenarios;
module-root flutter build apk; add-to-app newDsl=true test; gradle unit
tests on both AGP axes.

Revert-safe until P10 lands (mutually tolerant with P6).
@reidbaker
reidbaker force-pushed the agp-apk-copy-versioncode branch from 53bcc7f to 910cd5d Compare August 6, 2026 14:37
pull Bot pushed a commit to Little-Star888/flutter that referenced this pull request Aug 12, 2026
…on documentation (flutter#190842)

There are 2 files in this pr. One is a document the ai used to keep
track of work. More importantly it acts kind of like issues so it
references the items in future prs. The second is user facing website
documentation. I do not know if we will use it verbatim but for the set
of prs lets treat that md doc as human understandable documentation that
we must understand before landing the next pr.

Reviewers: When the pr is out of draft and your comments are fully
addressed please prioritize this pr over other work. The review bar is
higher, the number of reviews has more people and the work for the next
pr is already done.
 - @reidbaker 
---
Standard review context for this pr stack

This is PR is part of an 11 pr stack to migrate the "newdsl"
`gradle-api` specifically in agp 9.1.0.
The complete stack has pass pre submits, post submits and customer
tests.
https://flutter-dashboard.appspot.com/#/build?repo=flutter&branch=experimental/agp-gradle-api

All of the code was LLM authored. A mix of manual prompting, automatic
prompting, several models and adversarial review. The combined sessions
are enough that I cannot include relevant prompts like I have been doing
on other prs.

If you want to review the pr stack you can find it here. These prs will
be abandoned/closed as prs land into flutter/flutter.
1. reidbaker-agent#1 (branch:
agp-api-doc)
2. reidbaker-agent#2 (branch:
agp-internal-utils)
3. reidbaker-agent#3 (branch:
agp-buildmode-deps)
4. reidbaker-agent#4 (branch:
agp-plugin-buildtypes)
5. reidbaker-agent#5 (branch:
agp-ndk-fallback)
6. reidbaker-agent#6 (branch:
agp-assets-onvariants)
7. reidbaker-agent#7 (branch:
agp-apk-copy-versioncode)
8. reidbaker-agent#8 (branch:
agp-add-to-app)
9. reidbaker-agent#9 (branch:
agp-aar-script)
10. reidbaker-agent#10 (branch:
agp-newdsl-flip)
11. reidbaker-agent#11 (branch:
agp-gradle-api)

Follow up work is tracked in
flutter#190964

This work is urgent in the sense that we are worried that android will
publish agp 10 with no opt out but not so urgent that we are willing to
break flutter users because we didn't review or understand the code
because we were in a rush.

Breaking changes are expected as part of this work. There are patterns
the android team explicitly does not want apps to use and apis that have
no equivalent.

As part of the effort to ensure this work does not slip into ai slop,
prs from this stack will be reviewed by me (@reidbaker) before asking
for review. Then we will have 2 android expert reviewers also review the
every pr.

---
Agent authored pr description
This is PR 1 of 11 in the AGP 9.1.0 / public `gradle-api` migration
stack.

It adds the contributor-facing and website draft documentation for the
Flutter Gradle Plugin's migration to the Android Gradle Plugin public
Variant API, which unblocks building Flutter Android apps with AGP's
`newDsl=true` enabled.

Part of flutter#180137 and flutter#166550.

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

---------

Co-authored-by: reidbaker-agent <reidbaker@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants