Skip to content

chore: fix sample app Android build on Flutter 3.44.5#363

Merged
mrehan27 merged 1 commit into
mainfrom
fix-flutter-3.44.5-android-build
Jul 9, 2026
Merged

chore: fix sample app Android build on Flutter 3.44.5#363
mrehan27 merged 1 commit into
mainfrom
fix-flutter-3.44.5-android-build

Conversation

@mrehan27

@mrehan27 mrehan27 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Summary

The sample apps' Android build broke when CI's Flutter stable channel auto-updated 3.44.4 → 3.44.5:

> Could not create task ':app:copyJniLibsflutterBuildDebug'.
   > Task with name 'compileFlutterBuildDebug' not found in project ':app'.

Root cause

Flutter 3.44.5's Gradle plugin creates copyJniLibs<variant> through the new AGP variant API and looks up the compileFlutterBuild<variant> task that the legacy applicationVariants callback registers. Both sample apps' app/build.gradle used the eager tasks.whenTaskAdded { } API, which forced copyJniLibs… 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 main checkout with 3.44.5, and fails before any CustomerIO dependency resolution.

Fix

Replace the deprecated eager whenTaskAdded with the lazy tasks.matching { }.configureEach { } API (the recommended replacement), so the compressReleaseAssets → copyFlutterAssetsRelease dependency is wired without forcing early task realization.

-    tasks.whenTaskAdded { task ->
-        if (task.name == 'compressReleaseAssets') {
-            task.dependsOn 'copyFlutterAssetsRelease'
-        }
-    }
+    tasks.matching { it.name == 'compressReleaseAssets' }.configureEach {
+        dependsOn 'copyFlutterAssetsRelease'
+    }

Applied to both sample apps (flutter_sample_spm + flutter_sample_cocoapods).

Also commits the android.builtInKotlin=false / android.newDsl=false flags that Flutter 3.44.5's migrator writes to each app's gradle.properties on 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: clean flutter clean + flutter build apk --debug → ✅
  • flutter_sample_cocoapods: clean build → ✅

Notes

  • Not related to the geofence work — this is a general sample-app toolchain fix, hence targeting main (to be back-merged into feature/geofence-on-device).
  • Out of scope / follow-up: Flutter 3.44.5 also warns that Gradle 8.11.1, AGP 8.9.3, and Kotlin 2.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 / copyJniLibs task ordering.

In each app's app/build.gradle, the eager tasks.whenTaskAdded hook for compressReleaseAssets → copyFlutterAssetsRelease is replaced with tasks.matching { }.configureEach, so that dependency is applied lazily and Gradle no longer realizes Flutter JNI tasks too early during configuration.

Each sample's gradle.properties now commits android.builtInKotlin=false and android.newDsl=false from 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.

@mrehan27 mrehan27 requested a review from a team as a code owner July 7, 2026 16:38
@mrehan27 mrehan27 self-assigned this Jul 7, 2026
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
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.


  • flutter_sample_spm: 363.1.0 (29724068)

@mrehan27 mrehan27 force-pushed the fix-flutter-3.44.5-android-build branch from 0274e8f to c4ee16e Compare July 7, 2026 16:46
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>
@mrehan27 mrehan27 force-pushed the fix-flutter-3.44.5-android-build branch from c4ee16e to 69f2c45 Compare July 7, 2026 16:53
@mrehan27 mrehan27 merged commit ef33eef into main Jul 9, 2026
15 checks passed
@mrehan27 mrehan27 deleted the fix-flutter-3.44.5-android-build branch July 9, 2026 17:14
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