Repository navigation
[FGP] Offset split-APK versionCodes from a manifest-only versionCode - #196561
Conversation
- Apply plain-language and flutter/website style conventions across both
3.50 Android build breaking-change pages (imperative task headings,
explicit affected vs unaffected triage, `-` list markers, no manual
table footnotes or inflected code spans, and semantic line breaks).
- Fix technical findings verified against Flutter 3.50.0:
- Clarify how to inspect current AGP/Gradle/KGP/JDK versions and what
`flutter analyze --suggestions` actually reports.
- Complete the trimmed AGP error message, add 3.44 template Gradle
9.1.0 and Gradle/KGP no-advance-warning ranges, and fix the broken
AGP/Gradle compatibility table anchor (`about-agp#updating-gradle`).
- Clarify that KGP still must be >= 2.4.10 when `builtInKotlin=false`.
- Fix `copyFlutterApks<Variant>` visibility (`./gradlew tasks --all`),
3.47 library plugin build-type copying, softened `LibraryBuildType`
debuggability note, `onVariants` task lookup (`tasks.matching`),
preview `compileSdk` comparison, `flutter run`/`flutter build`
migrator scope, Timeline pre-release versions, and master PR links.
- Replace `[-<abi>][-<flavor>]` inline code notation that triggered
`dash_site check-link-references` failures.
- Add dedicated split-per-ABI `versionCode` migration guidance and the
`-P force-version-code-ignoring-abi=true` escape hatch, with explicit
`TODO(reidbaker)` blocks for the undecided `flutter/flutter#196561`
`3.50.x` cherry-pick.
|
@mboetger adding you as an fyi this is not quite ready for review I will take it out of draft when it is ready |
bkonyi
left a comment
There was a problem hiding this comment.
Left a few comments from an initial review pass (mainly around variant.sources.manifests.all.flatMap failing task-graph resolution when a generated manifest task like GenerateEngineFlagsManifestTask is registered).
(Note: This review was posted by an AI agent on behalf of @bkonyi.)
There was a problem hiding this comment.
Code Review
This pull request updates the Flutter Gradle plugin to resolve the base versionCode from the variant's manifest sources when it is not declared in the DSL during --split-per-abi builds. It introduces a new ManifestVersionCodeTask and helper class to parse the manifests, along with corresponding unit and integration tests. The review feedback suggests catching general exceptions rather than only SAXException during manifest parsing to prevent build crashes, and using Gradle's idiomatic providers.fileContents API to safely and lazily read the resolved version code file.
| } catch (e: SAXException) { | ||
| return Result.Unresolved("$manifest could not be parsed (${e.message})") | ||
| } |
There was a problem hiding this comment.
The DocumentBuilder.parse method can throw both SAXException and IOException. Catching only SAXException means any IOException (or other runtime exceptions) will propagate and crash the Gradle build with a cryptic stack trace. Catching Exception here is safer and ensures that any parsing or reading error is gracefully handled and returned as Result.Unresolved.
| } catch (e: SAXException) { | |
| return Result.Unresolved("$manifest could not be parsed (${e.message})") | |
| } | |
| } catch (e: Exception) { | |
| return Result.Unresolved("$manifest could not be parsed (${e.message})") | |
| } |
There was a problem hiding this comment.
Addressed in 7233196.
Partially applied. ManifestVersionCodeTaskHelper.readVersionCode now catches IOException alongside SAXException and turns both into actionable build errors (covered by a missing manifest is not found). Kept the catch list narrow rather than catching Exception so unexpected runtime exceptions in Flutter's own code surface with a full stack trace instead of being masked as a manifest parse error.
| return task.flatMap { it.versionCodeFile }.map { | ||
| it.asFile | ||
| .readText() | ||
| .trim() | ||
| .toInt() | ||
| } |
There was a problem hiding this comment.
Manually reading the file contents using readText() inside a provider map can lead to issues if the provider is queried prematurely (e.g., during configuration time by other plugins or build scripts), throwing a FileNotFoundException. Using Gradle's idiomatic providers.fileContents API is much safer and more robust. It lazily reads the file contents and is fully compatible with Gradle's configuration caching and lazy configuration model.
return project.providers.fileContents(task.flatMap { it.versionCodeFile }).asText.map {
it.trim().toInt()
}There was a problem hiding this comment.
Declined, because switching to providers.fileContents(...) drops the task dependency on ManifestVersionCodeTask. Verified with a ProjectBuilder test:
- Wiring
task.flatMap { it.versionCodeFile }.map { it.asFile.readText() }into a consumer's input preserves the task dependency ([produce]). Querying it before:produceruns throwsInvalidUserCodeException: Querying the mapped value of ... before task ':produce' has completed is not supported, not an opaqueFileNotFoundException. - Wiring
providers.fileContents(task.flatMap { it.versionCodeFile }).asTextinto a consumer's input drops the task dependency ([]). AGP's manifest task wouldn't wait forManifestVersionCodeTaskto run, and an early query silently evaluates to absent.
Kept task.flatMap { it.versionCodeFile }.map { ... } and documented this rule in gradle/AGENTS.md Rule 3.
| * other tasks (with `addGeneratedManifestFile`, as Flutter's engine flags manifest is). Gradle | ||
| * cannot query a provider derived from those files before the task graph runs. | ||
| */ | ||
| @DisableCachingByDefault(because = "Reading a few small files is faster than the build cache") |
There was a problem hiding this comment.
"Reading a few small files is faster than the build cache" what is the evidance this is true. In general I trust gradles abiliy to cache over custom caching rules.
There was a problem hiding this comment.
Addressed in 7233196.
I didn't have benchmarks backing that claim. Switched ManifestVersionCodeTask to @CacheableTask with a single @InputFile annotated with @PathSensitive(PathSensitivity.RELATIVE) (per gradle/AGENTS.md Rule 5), so cache hits work across machines and checkouts. variantName is marked @Internal since it's only used in the failure message and Gradle never caches failed tasks, allowing variants that share the same main manifest to share a cache entry.
| * The `android:versionCode` of [variant]'s manifest sources, read by a | ||
| * [ManifestVersionCodeTask] that fails if it cannot be resolved. | ||
| */ | ||
| private fun manifestVersionCode( |
There was a problem hiding this comment.
Is this the correct file for this function to live long term? Should this logic live in the helper?
There was a problem hiding this comment.
Addressed in 7233196.
Moved to tasks/ManifestVersionCodeTaskHelper.kt (replacing top-level ManifestVersionCode.kt), matching the existing EnableHcppManifestTask / EnableHcppManifestTaskHelper split where the task stays thin and the helper owns registration and XML parsing. ManifestVersionCodeTaskHelper.registerTask(project, variant) now registers the task and returns the Provider<Int>, leaving FlutterPlugin.configureSplitPerAbiVersionCodes to choose between the DSL value and the manifest fallback.
| variantName.set(variant.name) | ||
| versionCodeFile.set( | ||
| project.layout.buildDirectory.file( | ||
| "intermediates/flutter_manifest_version_code/${variant.name}/version_code.txt" |
There was a problem hiding this comment.
This is a string based file path that depends on androids implementation. Is there a type safe way we can get this value? If not why is this safe to add?
There was a problem hiding this comment.
Addressed in 7233196.
This path doesn't come from AGP. It's an internal output file written only by ManifestVersionCodeTask and read only by our own provider in ManifestVersionCodeTaskHelper.registerTask; AGP never touches the file and only receives the parsed Int on output.versionCode.
- Why not
variant.artifacts? AGP'svariant.artifactsAPI is closed to AGP's ownArtifacttypes, so there isn't a typed AGP artifact slot for a Flutter-internal intermediate file. - Why this path is safe: It follows the same scratch-output pattern FGP already uses for
GenerateEngineFlagsManifestTaskandFlutterTask'sintermediateDir, and now usesFlutterPluginConstants.INTERMEDIATES_DIR. Consumers read the file viatask.flatMap { it.versionCodeFile }rather than reconstructing the path string, so nothing outsideregisterTaskdepends on the layout. - Why not
intermediates/flutter/<variant>/?FlutterTaskdeclares that directory as its@OutputDirectory, and overlapping task outputs disable Gradle build caching. Givingflutter_manifest_version_code/<variant>/version_code.txtits own subdirectory keeps both tasks cacheable.
| ) | ||
| ) | ||
| } | ||
| // The task output carries the task dependency, so AGP's manifest task runs after it. |
There was a problem hiding this comment.
Addressed in 7233196.
That comment was too terse. What it meant: returning task.flatMap { it.versionCodeFile }.map { ... } preserves the Gradle task dependency on ManifestVersionCodeTask. When we pass that provider to output.versionCode, AGP's processManifest task consumes it as an input, so Gradle knows to run ManifestVersionCodeTask before processManifest. Rewrote the comment in ManifestVersionCodeTaskHelper.registerTask to spell that out directly.
| fun from(manifests: List<Pair<String, ByteArray?>>): Result { | ||
| val factory = DocumentBuilderFactory.newInstance() | ||
| factory.isNamespaceAware = true | ||
| factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true) |
There was a problem hiding this comment.
Addressed in 7233196.
http://apache.org/xml/features/disallow-doctype-decl makes DocumentBuilder reject any XML input containing a <!DOCTYPE ...> declaration. Without it, DocumentBuilderFactory expands DTD entities by default, which allows XML external entity (XXE) file/URL reads (for example <!ENTITY x SYSTEM "file:///etc/passwd">) and recursive entity-expansion bombs ("billion laughs"). Disabling DOCTYPE is OWASP's primary hardening guidance for Java's DocumentBuilderFactory, and Android manifests never use DOCTYPE. Clarified the inline comment in ManifestVersionCodeTaskHelper.parse and added a unit test.
| * `android:versionCode` with `tools:remove`, or sets `tools:node="replace"` or | ||
| * `tools:node="strict"` on its root element. | ||
| */ | ||
| fun from(manifests: List<Pair<String, ByteArray?>>): Result { |
There was a problem hiding this comment.
This method is kind of hard to follow.
There was a problem hiding this comment.
Addressed in 7233196.
Agreed. Now that we match AGP and read only the main manifest instead of simulating overlay merging, ManifestVersionCodeTaskHelper.readVersionCode parses a single file's <manifest> root and checks android:versionCode in one flat when block: missing → non-integer → non-positive (<= 0) → Result.Found(versionCode).
| /** | ||
| * Whether [root]'s `tools:remove` lists `android:versionCode`, under any prefix bound to the | ||
| * Android namespace. | ||
| */ |
There was a problem hiding this comment.
Can you give me an example of what this looks like in practice?
There was a problem hiding this comment.
Addressed in 7233196.
That KDoc was for removesVersionCode, which handled an overlay manifest binding the Android namespace to a custom prefix inside tools:remove, like:
<!-- src/release/AndroidManifest.xml -->
<manifest xmlns:a="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:remove="a:versionCode">removesVersionCode is deleted now because AGP ignores overlays when resolving the variant's versionCode and reads only the main manifest. The only namespace handling left is isNamespaceAware = true + getAttributeNS(ANDROID_NAMESPACE, "versionCode"), so a main manifest with a custom prefix like <manifest xmlns:a="http://schemas.android.com/apk/res/android" a:versionCode="7"> still resolves to 7 (covered by unit test).
| val prefix = name.trim().substringBefore(':', missingDelimiterValue = "") | ||
| name.trim().substringAfter(':') == "versionCode" && | ||
| prefix.isNotEmpty() && | ||
| root.lookupNamespaceURI(prefix) == ANDROID_NAMESPACE |
There was a problem hiding this comment.
Addressed in 7233196.
Agreed, deleted removesVersionCode altogether. Splitting tools:remove strings by namespace prefix was only needed to simulate overlay manifest merging. Since AGP only reads versionCode from the main manifest, we don't need any tools: parsing at all.
There was a problem hiding this comment.
The test in this file is a bit hard to follow can you make it easier for maintainers?
There was a problem hiding this comment.
Addressed in 7233196.
Refactored the new manifest-fallback tests into group('versionCode set only in AndroidManifest.xml') and replaced the four-flag helper with small, descriptive steps so each test reads top-to-bottom (_removeDslVersionCode, _addManifestAttributes(appDir, 'debug', ...), _addGradleProperties, _buildSplitPerAbiApks, _expectSplitApkVersionCodes(appDir, build, base: 7)). Left the pre-existing _assertSplitPerAbiVersionCodes tests untouched to keep the diff scoped to this change; happy to clean those up in a follow-up PR if you'd like.
- Read the manifests in ManifestVersionCodeTask instead of a flatMap over ManifestFiles.all. The flatMap failed task graph resolution when a task generates a manifest, such as -Pflutter.engineShellArgs. - Use the main manifest's integer versionCode when it has one, as AGP injects it over overlays. Otherwise the highest-priority manifest wins. - Parse manifests from bytes (BOM, encoding), silence Xerces stderr, and treat tools:node=replace/strict as unresolved only when the manifest declares no versionCode itself. - Fold the generated-manifest and debug-overlay cases into one integration case and drop the duplicate enableLegacyApi=false case.
Scaled by the local macOS run, where the 3 manifest cases added 56s to the 105s of the 4 existing cases.
From an adversarial review pass.
…ache the task AGP 9.3.1 reads a variant's DSL-less versionCode only from the main source set's manifest, and injects it into the merged manifest only when it is positive. Match that instead of simulating overlay merging, which removes the tools:remove, tools:node, and namespace-prefix handling. A versionCode of 0 or less now fails the build with the same actionable message. - Move ManifestVersionCode into tasks/ManifestVersionCodeTaskHelper, which also registers the task, following the EnableHcppManifestTaskHelper pattern. - Make ManifestVersionCodeTask @CacheableTask with one RELATIVE @InputFile. - Catch IOException next to SAXException. - Restore the GradleException and assertTrue imports in FlutterPluginTest that the rebase onto flutter#196465 dropped. - Restructure the new split-per-abi integration tests into a group of linear tests with small named helpers. - Add gradle/AGENTS.md rules for task-produced variant sources.
95904cc to
7233196
Compare
…back # Conflicts: # packages/flutter_tools/gradle/src/main/kotlin/FlutterPlugin.kt
…sionCode (#196923) ### Issue Link: #196559 Companion beta cherry-pick: #196924 ### Impact Description: [#193693](#193693) migrated per-ABI `versionCode` offsetting to AGP's public Variant API and shipped in 3.50.0 and 3.51.0-0.1.pre. Since #193693, `--split-per-abi` builds read the base `versionCode` only from the `android {}` DSL instead of falling back to `AndroidManifest.xml` as 3.47 did. Apps that set `android:versionCode` in `AndroidManifest.xml` without a DSL `versionCode` get the same `versionCode` on every split APK. The build only logs an error, and Google Play rejects split APKs that share a `versionCode`, blocking production releases. In addition, with `-P force-version-code-ignoring-abi=true` and no `versionCode` set anywhere, Flutter shipped split APKs with no `versionCode` attribute. Android reads a missing `versionCode` as `0`, which installs fresh but fails to update a versioned build with `INSTALL_FAILED_VERSION_DOWNGRADE`. Google Play also rejects APKs without a positive `versionCode`. This cherry-pick, [#196561](#196561) (`a61f510cd52`), reads `android:versionCode` from the main manifest in a cacheable task when `android {}` sets none, restoring 3.47's per-ABI offsets. With `-P force-version-code-ignoring-abi=true`, it applies that manifest value unchanged. It also offsets `versionCode` values set in `finalizeDsl`, and fails instead of overflowing `Int` when the offset exceeds `2147483647`. Behavior change: without a positive decimal `versionCode` in `android {}` or the main manifest, `--split-per-abi` builds now fail (including with `-P force-version-code-ignoring-abi=true`). The error tells the developer to set `versionCode = flutter.versionCode` in `defaultConfig` (or on each product flavor). Impact estimate for approvers (Googlers only): [go/flutter-i196561-broken-users-impact](http://go/flutter-i196561-broken-users-impact) estimates that fewer than 0.01% of Flutter Android apps hit this failure. Failing at build time is better than silently shipping split APKs that share a `versionCode`. ### Changelog Description: [flutter/196559] When building Android APKs with --split-per-abi and versionCode set only in AndroidManifest.xml, every split APK gets the same versionCode. [flutter/195006] When building Android apps with Gradle's configuration cache enabled, Gradle can't store the cache entry, so it never reuses it. ### Workaround: Set `versionCode = flutter.versionCode` (or a literal integer) in `defaultConfig` or on each product flavor in `android/app/build.gradle.kts` (`build.gradle`). ### Risk: What is the risk level of this cherry-pick? ### Test Coverage: Are you confident that your fix is well-tested by automated tests? ### Validation Steps: 1. Run `flutter create app && cd app`. 2. Remove `versionCode = flutter.versionCode` from `defaultConfig` in `android/app/build.gradle.kts`. 3. Add `android:versionCode="7"` to `<manifest>` in `android/app/src/main/AndroidManifest.xml`. 4. Run `flutter build apk --split-per-abi`, then inspect each APK in `build/app/outputs/flutter-apk/` with `aapt2 dump badging`. The split APKs report `versionCode` `1007` (`armeabi-v7a`), `2007` (`arm64-v8a`), and `4007` (`x86_64`). 5. Covered by `ManifestVersionCodeTaskHelperTest` and `FlutterPluginTest` (on AGP 9.1.1 and 9.3.1) and `flutter_build_apk_split_per_abi_test.dart` (including configuration-cache reuse with `newDsl` and `enableLegacyApi=false`). ### Bundled change and conflict resolution: This PR also cherry-picks [#195006](#195006) (`fe070b10d2b`, merged on `master` October 22; already in 3.51, not in 3.50). On 3.50, `DependencyVersionChecker.configureMinSdkCheck` captured `Project` and `Variant` inside `doLast`, breaking Gradle's configuration cache. Without #195006, #196561's configuration-cache integration test fails on `flutter-3.50-candidate.0`; bundling it also fixes configuration-cache reuse for 3.50.1 users. PR #195006 applied cleanly. When cherry-picking #196561 (`a61f510cd52`), the only conflict was `dev/bots/tool_test_durations.json`, which does not exist on `flutter-3.50-candidate.0` and was dropped (`git rm`). All other changed files are byte-identical to `master`.
The tool_test_durations.json change from flutter#196561 only rebalances CI shards. On 3.51 it moves test_test.dart into a Mac shard where an earlier test leaves SwiftPM plugin copies under dev/automated_tests/flutter_test/build, which the --experimental-faster-testing cases then try to run. Keeping 3.51's durations avoids that unrelated failure; the stable cherry-pick drops this file too.
…onCode (#196924) ### Issue Link: #196559 Companion stable cherry-pick: #196923 ### Impact Description: [#193693](#193693) migrated per-ABI `versionCode` offsetting to AGP's public Variant API and shipped in 3.50.0 and 3.51.0-0.1.pre. Since #193693, `--split-per-abi` builds read the base `versionCode` only from the `android {}` DSL instead of falling back to `AndroidManifest.xml` as 3.47 did. Apps that set `android:versionCode` in `AndroidManifest.xml` without a DSL `versionCode` get the same `versionCode` on every split APK. The build only logs an error, and Google Play rejects split APKs that share a `versionCode`, blocking production releases. In addition, with `-P force-version-code-ignoring-abi=true` and no `versionCode` set anywhere, Flutter shipped split APKs with no `versionCode` attribute. Android reads a missing `versionCode` as `0`, which installs fresh but fails to update a versioned build with `INSTALL_FAILED_VERSION_DOWNGRADE`. Google Play also rejects APKs without a positive `versionCode`. This cherry-pick, [#196561](#196561) (`a61f510cd52`), reads `android:versionCode` from the main manifest in a cacheable task when `android {}` sets none, restoring 3.47's per-ABI offsets. With `-P force-version-code-ignoring-abi=true`, it applies that manifest value unchanged. It also offsets `versionCode` values set in `finalizeDsl`, and fails instead of overflowing `Int` when the offset exceeds `2147483647`. It applied to `flutter-3.51-candidate.0` without conflicts. The code is byte-identical to `a61f510cd52`; the only difference is that `dev/bots/tool_test_durations.json` keeps its 3.51 contents, because master's test-duration data changes how the Mac tool integration tests are sharded on 3.51. Behavior change: without a positive decimal `versionCode` in `android {}` or the main manifest, `--split-per-abi` builds now fail (including with `-P force-version-code-ignoring-abi=true`). The error tells the developer to set `versionCode = flutter.versionCode` in `defaultConfig` (or on each product flavor). Impact estimate for approvers (Googlers only): [go/flutter-i196561-broken-users-impact](http://go/flutter-i196561-broken-users-impact) estimates that fewer than 0.01% of Flutter Android apps hit this failure. Failing at build time is better than silently shipping split APKs that share a `versionCode`. ### Changelog Description: [flutter/196559] When building Android APKs with --split-per-abi and versionCode set only in AndroidManifest.xml, every split APK gets the same versionCode. The stable cherry-pick (#196923) also adds a [flutter/195006] entry for the configuration cache fix it bundles. That fix is already in 3.51, so this beta cherry-pick has no second entry. ### Workaround: Set `versionCode = flutter.versionCode` (or a literal integer) in `defaultConfig` or on each product flavor in `android/app/build.gradle.kts` (`build.gradle`). ### Risk: What is the risk level of this cherry-pick? ### Test Coverage: Are you confident that your fix is well-tested by automated tests? ### Validation Steps: 1. Run `flutter create app && cd app`. 2. Remove `versionCode = flutter.versionCode` from `defaultConfig` in `android/app/build.gradle.kts`. 3. Add `android:versionCode="7"` to `<manifest>` in `android/app/src/main/AndroidManifest.xml`. 4. Run `flutter build apk --split-per-abi`, then inspect each APK in `build/app/outputs/flutter-apk/` with `aapt2 dump badging`. The split APKs report `versionCode` `1007` (`armeabi-v7a`), `2007` (`arm64-v8a`), and `4007` (`x86_64`). 5. Covered by `ManifestVersionCodeTaskHelperTest` and `FlutterPluginTest` (on AGP 9.1.1 and 9.3.1) and `flutter_build_apk_split_per_abi_test.dart` (including configuration-cache reuse with `newDsl` and `enableLegacyApi=false`).
flutter/flutter@06f32f8...e8cc6f3 2026-11-19 [email protected] Roll Skia from 280e0965687d to 3dfb69d709c7 (1 revision) (flutter/flutter#196970) 2026-11-19 [email protected] Update outdated `_formattedValues` documentation (flutter/flutter#195765) 2026-11-19 [email protected] [Impeller] Fix Vulkan GPU frame time metrics in benchmarks (flutter/flutter#196339) 2026-11-19 [email protected] Windows: Enable D3D11 multithread protection on ANGLE's device (flutter/flutter#196897) 2026-11-19 [email protected] Roll Skia from 7356c7627e87 to 280e0965687d (1 revision) (flutter/flutter#196957) 2026-11-19 [email protected] Roll Dart SDK from 091f346ad95c to d8d40cf9c21b (2 revisions) (flutter/flutter#196949) 2026-11-19 [email protected] Roll Skia from 73b9219fd1fa to 7356c7627e87 (4 revisions) (flutter/flutter#196951) 2026-11-19 [email protected] Roll Skia from 7bca23228537 to 73b9219fd1fa (1 revision) (flutter/flutter#196948) 2026-11-19 [email protected] [libimpeller] Fix swapped x and y glyph coordinates (flutter/flutter#196552) 2026-11-19 [email protected] [ios][spm]When using cocoapods plugin, give instruction that plugins may just need update (flutter/flutter#195853) 2026-11-19 [email protected] [web] Let the browser handle Control+wheel zoom outside of macOS (flutter/flutter#193362) 2026-11-19 [email protected] Fix focus violation when canRequestFocus set to false for all siblings in same build (flutter/flutter#191536) 2026-11-19 [email protected] Roll Skia from 9fc4f9e23d56 to 7bca23228537 (10 revisions) (flutter/flutter#196941) 2026-11-19 [email protected] Roll Dart SDK from 753488ede427 to 091f346ad95c (2 revisions) (flutter/flutter#196940) 2026-11-19 [email protected] iOS: Convert platform views to points with the frame's pixel ratio (flutter/flutter#196858) 2026-11-19 [email protected] [engine] Defer default font manager resolution to first use for platforms that have a prefetching API only (flutter/flutter#196377) 2026-11-18 [email protected] [flutter_tools] Add example app to package template and decouple platform configurations (flutter/flutter#192441) 2026-11-18 [email protected] [flutter_tools] Rebuild asset bundle when generated manifest content changes (flutter/flutter#191638) 2026-11-18 [email protected] Roll Skia from b11d69796f71 to 9fc4f9e23d56 (2 revisions) (flutter/flutter#196909) 2026-11-18 [email protected] [flutter_tools] Bump cupertino_icons to ^2.0.0 in app and module templates (flutter/flutter#196828) 2026-11-18 [email protected] Update iOS plugin language instructions (flutter/flutter#196614) 2026-11-18 [email protected] iOS: Add tests for rounded rect clips with per-corner/elliptical radii (flutter/flutter#196854) 2026-11-18 [email protected] Revert: [flutter_tools] Migrate lib/runner.dart off runInContext and overrides (flutter/flutter#196926) 2026-11-18 [email protected] Revert: Move macOS desktop builds to ThinLTO (flutter/flutter#196917) 2026-11-18 [email protected] [FGP] Offset split-APK versionCodes from a manifest-only versionCode (flutter/flutter#196561) 2026-11-18 [email protected] [flutter_tools] Migrate lib/runner.dart off runInContext and overrides (flutter/flutter#196387) 2026-11-18 [email protected] docs: remove broken image references from dev/snippets/README.md (flutter/flutter#195587) 2026-11-18 [email protected] Remove the FGP AGP-public-API migration coordination docs (flutter/flutter#196733) 2026-11-18 [email protected] [web] Skip stale safeBlur focus transfer when the element was refocused (flutter/flutter#196550) 2026-11-18 [email protected] Roll Skia from 81ee7327e81c to b11d69796f71 (4 revisions) (flutter/flutter#196900) If this roll has caused a breakage, revert this CL and set the roller to dry run mode using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…sionCode (#196923) ### Issue Link: flutter/flutter#196559 Companion beta cherry-pick: flutter/flutter#196924 ### Impact Description: [#193693](flutter/flutter#193693) migrated per-ABI `versionCode` offsetting to AGP's public Variant API and shipped in 3.50.0 and 3.51.0-0.1.pre. Since #193693, `--split-per-abi` builds read the base `versionCode` only from the `android {}` DSL instead of falling back to `AndroidManifest.xml` as 3.47 did. Apps that set `android:versionCode` in `AndroidManifest.xml` without a DSL `versionCode` get the same `versionCode` on every split APK. The build only logs an error, and Google Play rejects split APKs that share a `versionCode`, blocking production releases. In addition, with `-P force-version-code-ignoring-abi=true` and no `versionCode` set anywhere, Flutter shipped split APKs with no `versionCode` attribute. Android reads a missing `versionCode` as `0`, which installs fresh but fails to update a versioned build with `INSTALL_FAILED_VERSION_DOWNGRADE`. Google Play also rejects APKs without a positive `versionCode`. This cherry-pick, [#196561](flutter/flutter#196561) (`a61f510cd52`), reads `android:versionCode` from the main manifest in a cacheable task when `android {}` sets none, restoring 3.47's per-ABI offsets. With `-P force-version-code-ignoring-abi=true`, it applies that manifest value unchanged. It also offsets `versionCode` values set in `finalizeDsl`, and fails instead of overflowing `Int` when the offset exceeds `2147483647`. Behavior change: without a positive decimal `versionCode` in `android {}` or the main manifest, `--split-per-abi` builds now fail (including with `-P force-version-code-ignoring-abi=true`). The error tells the developer to set `versionCode = flutter.versionCode` in `defaultConfig` (or on each product flavor). Impact estimate for approvers (Googlers only): [go/flutter-i196561-broken-users-impact](http://go/flutter-i196561-broken-users-impact) estimates that fewer than 0.01% of Flutter Android apps hit this failure. Failing at build time is better than silently shipping split APKs that share a `versionCode`. ### Changelog Description: [flutter/196559] When building Android APKs with --split-per-abi and versionCode set only in AndroidManifest.xml, every split APK gets the same versionCode. [flutter/195006] When building Android apps with Gradle's configuration cache enabled, Gradle can't store the cache entry, so it never reuses it. ### Workaround: Set `versionCode = flutter.versionCode` (or a literal integer) in `defaultConfig` or on each product flavor in `android/app/build.gradle.kts` (`build.gradle`). ### Risk: What is the risk level of this cherry-pick? ### Test Coverage: Are you confident that your fix is well-tested by automated tests? ### Validation Steps: 1. Run `flutter create app && cd app`. 2. Remove `versionCode = flutter.versionCode` from `defaultConfig` in `android/app/build.gradle.kts`. 3. Add `android:versionCode="7"` to `<manifest>` in `android/app/src/main/AndroidManifest.xml`. 4. Run `flutter build apk --split-per-abi`, then inspect each APK in `build/app/outputs/flutter-apk/` with `aapt2 dump badging`. The split APKs report `versionCode` `1007` (`armeabi-v7a`), `2007` (`arm64-v8a`), and `4007` (`x86_64`). 5. Covered by `ManifestVersionCodeTaskHelperTest` and `FlutterPluginTest` (on AGP 9.1.1 and 9.3.1) and `flutter_build_apk_split_per_abi_test.dart` (including configuration-cache reuse with `newDsl` and `enableLegacyApi=false`). ### Bundled change and conflict resolution: This PR also cherry-picks [#195006](flutter/flutter#195006) (`fe070b10d2b`, merged on `master` October 22; already in 3.51, not in 3.50). On 3.50, `DependencyVersionChecker.configureMinSdkCheck` captured `Project` and `Variant` inside `doLast`, breaking Gradle's configuration cache. Without #195006, #196561's configuration-cache integration test fails on `flutter-3.50-candidate.0`; bundling it also fixes configuration-cache reuse for 3.50.1 users. PR #195006 applied cleanly. When cherry-picking #196561 (`a61f510cd52`), the only conflict was `dev/bots/tool_test_durations.json`, which does not exist on `flutter-3.50-candidate.0` and was dropped (`git rm`). All other changed files are byte-identical to `master`.
Reran `dart dev/bots/update_tool_test_durations.dart` added in flutter#195628. The weights were last sampled a few weeks ago and tests have changed since. For example flutter#196561 took `flutter_build_apk_split_per_abi_test.dart` from 263 to 412 seconds on Linux. With the old weights the seven Linux tool_integration_tests shards get 13.5 to 16.8 minutes of tests under the new durations, the ten Mac shards 11.6 to 13.6, and the fifteen Windows shards 9.4 to 12.5. The new weights even those out. The script now samples 10 builds per subshard by default, up from 3. On Linux, 15 files differed by at least 10 seconds and 10% between a 3-build and a 10-build sample. Also the script threw `No web builders found for macos` because `Mac web_tool_tests_1` and `_2` no longer have the shard total in their names as of flutter#196276. The web and commands regex now accept names with or without it. ## 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]. - [ ] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant in-code documentation (doc comments with `///`). - [x] If this PR introduces a new feature or capability, I created and linked a website documentation issue or PR in [flutter/website] (or verified none is needed). - [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. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [AI contribution guidelines]: https://github.com/flutter/flutter/blob/main/CONTRIBUTING.ai.md [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [flutter/website]: https://github.com/flutter/website [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Fixes #196559
With
--split-per-abi, Flutter gives each split APK the versionCodeABI * 1000 + base. Since #193693, Flutter takesbaseonly from theandroid {}DSL. Apps that setandroid:versionCodeonly inAndroidManifest.xmlgot the same versionCode on every split APK, and Google Play rejects APKs that share a versionCode. The build only logged an error.What changed
resolveManifestVersionCode<Variant>(ManifestVersionCodeTask), readsandroid:versionCodefrom the main manifest and writes it to a file. Each split output's versionCode is a provider of that task's output, so AGP's manifest task runs after it.src/main/AndroidManifest.xmlunlesssourceSets.mainmoves it), and AGP injects it into the merged manifest over every overlay when it is positive. Flutter reads the same file and requires the same positive integer. Build-type, flavor, and generated manifests are not read.variant.sources.manifests.all, which can also contain manifests that other tasks generate (for example Flutter's engine flags manifest with-Pflutter.engineShellArgs). The list is a task input, so it is only read when the task runs.android.compatibility.enableLegacyApi=false,android.newDsl=trueandandroid.builtInKotlin=true.defaultConfigor on a product flavor, nothing changes.Behavior change
If Flutter cannot find a base versionCode in
android {}or the main manifest, a--split-per-abibuild now fails with or without-P force-version-code-ignoring-abi=true. Before, builds without the flag only logged an error. With the flag and no DSL versionCode, Flutter skipped its check—a pre-existing gap in 3.50.0 (3.47.9 skipped the offset under the flag too). With-P force-version-code-ignoring-abi=trueand a valid main-manifestandroid:versionCode, every split APK gets that value unchanged (a DSL versionCode is still left to AGP).When
android {}sets no versionCode, the build fails if:android:versionCode(even if a build-type or flavor manifest does),${vc}placeholder, an@integer/...resource, or0x10, orThe error names the variant and the cause. It tells you to set
versionCode = flutter.versionCodeindefaultConfig(or on each product flavor):The same error applies with and without
-P force-version-code-ignoring-abi=true. Without Flutter's check, AGP either omitsversionCodeor fails:aapt2 dump badgingshowsversionCode=''). Android reads a missing versionCode as0: fresh installs succeed, but Google Play rejects those APKs, and updating a build with a positive versionCode fails withINSTALL_FAILED_VERSION_DOWNGRADE.Error while evaluating property 'variantOutputs.$0.versionCode' of task ':app:createDebugCompatibleScreenManifests'. > java.lang.NumberFormatException: For input string: "0x10". AGP parses this attribute withInteger.parseInt(seen withjavaponManifestDataKtin AGP 9.1.1 and 9.3.1), so a plainflutter build apkwithout--split-per-abifails the same way.A corner-case audit of this PR found two more problems, which are fixed here too:
androidComponents.finalizeDslis offset again. Since [AGP 9.1.0 Migration #7] Migrate the flutter-apk copy and per-ABI versionCode to the variant API #193693, Flutter read the DSL versionCodes in its ownfinalizeDslcallback. That callback runs before the app's, because the app applies Flutter in itsplugins {}block. SofinalizeDsl { it.defaultConfig.versionCode = 55 }was not seen, while Flutter 3.47 gave 1055 / 2055 / 4055. Flutter now reads the DSL on its firstonVariantscall. AGP runsonVariantsonly after everyfinalizeDslcallback (BasePlugin.createAndroidTasksrunsexecuteDslFinalizationBlocksbeforecreateVariants), and the DSL can still be read then.Intfails the build. Before,versionCode = 2147482000wrapped around without a warning: arm64-v8a and x86_64 got negative values, and all 3 APKs ended up with versionCode 2147483000. Now both DSL and manifest versionCodes fail with:The largest base that works for all 3 ABIs is 2147479647.
Why this fails instead of logging an error
We tried keeping the old "log an error and continue" behavior for the case where no versionCode is set anywhere, and it doesn't work under the new DSL:
versionCode.process<Variant>MainManifestfails with "property 'versionCode' has no value". Gradle has no API to fall back to AGP's original value.enableLegacyApi=falseand the new DSL don't allow.So the choice is Flutter's clear error, or AGP's unclear one. The builds this now fails were already producing split APKs that all share a versionCode, which Google Play rejects.
Cherry-pick note
This PR is meant to be cherry-picked to 3.50 to fix #196559. That means a 3.50 point release would turn the previous error log into a build failure for apps that set no versionCode anywhere. Reviewers should decide explicitly whether that's acceptable for 3.50. The alternative is to land the failure on master only. If it ships, the release notes should say how to fix the error: set
versionCode = flutter.versionCodeindefaultConfig.Impact analysis for cherry-pick approvers (Googlers only): go/flutter-i196561-broken-users-impact. It estimates that the new failure affects fewer than 0.01% of Flutter Android apps, and explains why failing is better than silently shipping split APKs that share one versionCode.
Testing
Follow-up for
force-version-code-ignoring-abiwithout a DSL versionCode (657e7d0):FlutterPluginTestadds a case forforce-version-code-ignoring-abi=truewith no DSL versionCode (verifiesManifestVersionCodeTaskHelper.registerTaskis wired without the per-ABI offset, giving7rather than2007) and checks that the DSL + flag path sets no provider.ManifestVersionCodeTaskHelperTestchecks the updated message. All 298 Gradle unit tests pass on AGP 9.1.1 and 9.3.1; ktlint 1.5.0 is clean.flutter_build_apk_split_per_abi_testchecks that--split-per-abiwithout a versionCode fails both with and without-P force-version-code-ignoring-abi=true.Pixel_9_API_35(flutter build apk --debug --split-per-abi, AGP 9.3.1; "overvc=7" meansadb install -rover an installedversionCode=7build):ebfd1ed)657e7d0)vc,forcevc=''×3; fresh install OK (0); overvc=7:INSTALL_FAILED_VERSION_DOWNGRADEresolveManifestVersionCodeDebug0,forcevc=''×3; fresh OK (0); overvc=7:DOWNGRADE"0" … is not positive)7,forcevc=7OKvc, noforcevc=''; overvc=7:DOWNGRADE7, noforcevc=7OK--build-number=5±forceforce: 5 / 5 / 5; noforce: 1005 / 2005 / 4005Follow-up for the corner-case audit (254132c):
FlutterPluginTesthas 3 new cases:finalizeDslcallback sets is offset. This case fails when the DSL is read at apply time.armeabi-v7astill gets 2147483000, and thenarm64-v8afails with the overflow message.splitApkVersionCodeis tested at the boundary,Int.MAX_VALUE - 4000and- 3999.ManifestVersionCodeTaskHelperTestcovers${versionCode},@integer/version_code,0x10,+7,2147483647,2147483648,+2147483648and-99999999999. It also checks that the error does not mention the force flag.-Pflutter.internal.agpVersion=9.3.1. ktlint 1.5.0 is clean.flutter_build_apk_split_per_abi_testhas a new case. WithnewDsl,builtInKotlinandenableLegacyApi=false, the app setsversionCode = 55infinalizeDsl, and the test expects 1055 / 2055 / 4055. All 8 cases pass locally in 2m31s, and the new case takes 18s.tool_test_durations.jsonis scaled by that.--debug --split-per-abibuilds on AGP 9.1.1 and 9.3.1, withnewDsl,builtInKotlinandenableLegacyApi=false:finalizeDslsets 55, main manifest sets none,./gradlew :app:processDebugManifest -Psplit-per-abi=true --configuration-cache --configuration-cache-problems=failflutter build apk21474820002147479647defaultConfig2147482000(AGP 9.3.1)0x100, the build exits 0 and all 3 APKs haveversionCode=''. With${myVc}(the placeholder is set),@integer/app_version_codeor0x10, AGP fails withNumberFormatException.Earlier testing:
ManifestVersionCodeTaskHelperTest(positive, whitespace, a custom Android namespace prefix, missing, placeholder, 0 and negative, a DOCTYPE, malformed XML without stderr output, a missing file, UTF-16), plus 2FlutterPluginTestcases. One runs the task with a debug overlay and the main manifest written after configuration, and checks that the main manifest's value is used and the failure message. The other uses a task-generated manifest, and checks that building the task graph does not query it. All 293 Gradle unit tests pass, and ktlint 1.5.0 is clean.DependencyVersionChecker.ktrange): verified on both AGP 9.3.1 (template default, Gradle 9.5.0) and AGP 9.1.1 (minimum supported, Gradle 9.3.1) — all 293 Gradle unit tests (-Pflutter.internal.agpVersion=9.1.1) and all 7flutter_build_apk_split_per_abi_testcases pass on AGP 9.1.1.flutter_build_apk_split_per_abi_testhas 3 new cases, which read versionCodes withaapt2 dump badging. All 7 cases pass locally.7, asrc/debugoverlay9withtools:replace, and the generated engine flags manifest: expect 1007/2007/4007;newDslandenableLegacyApi=false: build, rebuild while reusing the cache, edit the manifest, and expect the new value;java.io, the configuration cache case fails (expected 1006, got 1007). With the earlierflatMapoverManifestFiles.all, a build with-Pflutter.engineShellArgsfails withQuerying the mapped value of … before task ':app:generateEngineFlagsManifestDebug' has completed is not supported, and so does the generated-manifestFlutterPluginTestcase (InvalidUserCodeException).flutter build apk --release --split-per-abion an app withnewDslandbuiltInKotlinon andenableLegacyApi=false:7defaultConfig5free= 11; flavorpaidfalls back todefaultConfig5${vc},tools:remove, or no versionCode-P force-version-code-ignoring-abi=trueThe table above ran before the review follow-ups. Flutter now reads only the main manifest, so the overlay rows fail unless the main manifest sets a positive versionCode, and the "overlay
9, main sets none" row below now fails with the message. After the first follow-up, I ran these--debug --split-per-abibuilds (and one--release) on a defaultflutter createapp with AGP 9.3.1:src/debugoverlay9withtools:replace, main7src/debugoverlay9, main sets nonesrc/debugoverlaytools:remove="android:versionCode", main77,-P flutter.engineShellArgs=..., debug and--releaseKnown issues
With
org.gradle.configuration-cache.problems=fail,flutter build apk(debug and release) still fails becauseFlutterTask(compileFlutterBuild<Variant>) readsTask.projectat execution time. That also happens on master. The configuration cache test setsproblems=warnfor that reason.On
--split-per-abibuilds whereandroid {}sets noversionCode, avariant.sources.manifests.addGeneratedManifestFiletask that also readsoutput.versionCodehits a circular task dependency withresolveManifestVersionCode<Variant>both with and without-P force-version-code-ignoring-abi=true; settingversionCode = flutter.versionCodeindefaultConfigavoids it.Cherry-pick
A 3-way merge of this PR onto
flutter-3.50-candidate.0(git merge-tree) is clean exceptdev/bots/tool_test_durations.json, which does not exist on that branch, so the cherry-pick should drop that file.Pre-launch Checklist
///).