chore: fix sample app Android build on Flutter 3.44.5#363
Merged
Conversation
Contributor
Sample app builds 📱Below you will find the list of the latest versions of the sample apps. It's recommended to always download the latest builds of the sample apps to accurately test the pull request.
|
0274e8f to
c4ee16e
Compare
Flutter 3.44.5's Android Gradle plugin creates copyJniLibs<variant> via the new
variant API and looks up the compileFlutterBuild<variant> task created by the
legacy applicationVariants callback. The eager tasks.whenTaskAdded {} in the
sample apps forced copyJniLibs to realize before that compile task was
registered, failing with "Task with name 'compileFlutterBuildDebug' not found".
Switch to the lazy tasks.matching {}.configureEach {} API (the recommended
replacement for the deprecated eager whenTaskAdded) so the dependency is wired
without forcing early task realization.
Also commit the android.builtInKotlin/newDsl=false flags that Flutter 3.44.5's
migrator writes to gradle.properties on every build; committing them keeps the
working tree clean instead of regenerating on each build.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
c4ee16e to
69f2c45
Compare
mahmoud-elmorabea
approved these changes
Jul 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The sample apps' Android build broke when CI's Flutter
stablechannel auto-updated 3.44.4 → 3.44.5:Root cause
Flutter 3.44.5's Gradle plugin creates
copyJniLibs<variant>through the new AGP variant API and looks up thecompileFlutterBuild<variant>task that the legacyapplicationVariantscallback registers. Both sample apps'app/build.gradleused the eagertasks.whenTaskAdded { }API, which forcedcopyJniLibs…to realize during configuration — before that compile task existed — so task creation failed.This is purely a toolchain incompatibility, not a dependency or SDK issue: it reproduces on a clean
maincheckout with 3.44.5, and fails before any CustomerIO dependency resolution.Fix
Replace the deprecated eager
whenTaskAddedwith the lazytasks.matching { }.configureEach { }API (the recommended replacement), so thecompressReleaseAssets → copyFlutterAssetsReleasedependency is wired without forcing early task realization.Applied to both sample apps (
flutter_sample_spm+flutter_sample_cocoapods).Also commits the
android.builtInKotlin=false/android.newDsl=falseflags that Flutter 3.44.5's migrator writes to each app'sgradle.propertieson every build — committing them keeps the working tree clean instead of regenerating (and dirtying) on each build. They opt out of the new Kotlin/DSL migration for now (behavior unchanged); the full migration is part of the toolchain-bump follow-up below.Verified locally (Flutter 3.44.5)
flutter_sample_spm: cleanflutter clean+flutter build apk --debug→ ✅flutter_sample_cocoapods: clean build → ✅Notes
main(to be back-merged intofeature/geofence-on-device).8.11.1, AGP8.9.3, and Kotlin2.1.21"will soon be dropped." Those are non-blocking deprecation warnings (build is green); the version bumps carry their own risk and will be handled in a separate PR.Note
Low Risk
Sample-app-only Gradle configuration changes with no product SDK or auth/data impact; behavior of the asset task dependency is preserved.
Overview
Restores Android builds for the flutter_sample_spm and flutter_sample_cocoapods sample apps after Flutter 3.44.5 broke configuration with
compileFlutterBuildDebug/copyJniLibstask ordering.In each app's
app/build.gradle, the eagertasks.whenTaskAddedhook forcompressReleaseAssets → copyFlutterAssetsReleaseis replaced withtasks.matching { }.configureEach, so that dependency is applied lazily and Gradle no longer realizes Flutter JNI tasks too early during configuration.Each sample's
gradle.propertiesnow commitsandroid.builtInKotlin=falseandandroid.newDsl=falsefrom the Flutter migrator so local builds stay clean without changing runtime behavior.Reviewed by Cursor Bugbot for commit 69f2c45. Bugbot is set up for automated code reviews on this repo. Configure here.