Skip to content

[flutter_tools] Migrate detectLowCompileSdkVersionOrNdkVersion to AGP task#184731

Open
reidbaker wants to merge 11 commits intoflutter:masterfrom
reidbaker:i184415-migrate-pre-flight-gradle-checks
Open

[flutter_tools] Migrate detectLowCompileSdkVersionOrNdkVersion to AGP task#184731
reidbaker wants to merge 11 commits intoflutter:masterfrom
reidbaker:i184415-migrate-pre-flight-gradle-checks

Conversation

@reidbaker
Copy link
Copy Markdown
Contributor

Migrates the evaluation of detectLowCompileSdkVersionOrNdkVersion from project.afterEvaluate to a modern Android Gradle Plugin (AGP) task-based approach.

Fixes #184415

Pre-launch Checklist

… task

Migrates the evaluation of detectLowCompileSdkVersionOrNdkVersion from project.afterEvaluate to a modern Android Gradle Plugin (AGP) task-based approach.
@reidbaker reidbaker requested a review from a team as a code owner April 7, 2026 19:18
@github-actions github-actions Bot added platform-android Android applications specifically tool Affects the "flutter" command-line tool. See also t: labels. labels Apr 7, 2026
@reidbaker reidbaker added the CICD Run CI/CD label Apr 7, 2026
@reidbaker reidbaker marked this pull request as draft April 7, 2026 19:20
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the Android SDK and NDK version validation logic into a dedicated Gradle task, ValidateCompileSdkVersionTask, which is now wired to run before the preBuild task. The changes include migrating the validation logic from FlutterPluginUtils and updating the test suite accordingly. Feedback was provided to improve Gradle performance by adhering to the Task Configuration Avoidance API, specifically by configuring the task lazily instead of forcing immediate realization.

Comment thread packages/flutter_tools/gradle/src/main/kotlin/FlutterPluginUtils.kt Outdated
@reidbaker
Copy link
Copy Markdown
Contributor Author

Leaving in draft until tests pass.

- Applied ktlint formatting using CI configuration
- Used editorconfig and ktlint-baseline from dev/bots/test/analyze-test-input
- Validated all changes pass ktlint checks
…ment on github for ways to resolve false positives
@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 9, 2026
@reidbaker reidbaker added the CICD Run CI/CD label Apr 9, 2026
@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 9, 2026
@reidbaker reidbaker added the CICD Run CI/CD label Apr 9, 2026
@reidbaker reidbaker marked this pull request as ready for review April 9, 2026 21:30
@reidbaker reidbaker requested a review from jesswrd April 9, 2026 21:30
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the Android SDK and NDK version validation logic by introducing a new 'ValidateCompileSdkVersionTask' and removing the legacy 'logPluginCompileSdkWarnings' and 'logPluginNdkWarnings' methods from 'FlutterPluginUtils'. The review identified several critical issues: missing imports for 'AndroidComponentsExtension', potential NullPointerExceptions when accessing Android extensions, and the need to restore default NDK version handling to prevent runtime crashes.

Comment thread packages/flutter_tools/gradle/src/main/kotlin/FlutterPluginUtils.kt
Comment thread packages/flutter_tools/gradle/src/main/kotlin/FlutterPluginUtils.kt
Comment thread packages/flutter_tools/gradle/src/main/kotlin/FlutterPluginUtils.kt Outdated
@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 10, 2026
@reidbaker reidbaker added the CICD Run CI/CD label Apr 10, 2026
@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 13, 2026
@reidbaker reidbaker added CICD Run CI/CD and removed CICD Run CI/CD labels Apr 13, 2026
@reidbaker reidbaker added the CICD Run CI/CD label Apr 13, 2026
@fluttergithubbot
Copy link
Copy Markdown
Contributor

An existing Git SHA, bb497efbc32b1866d5045bfbbfe387bb6c8b3c52, was detected, and no actions were taken.

To re-trigger presubmits after closing or re-opeing a PR, or pushing a HEAD commit (i.e. with --force) that already was pushed before, push a blank commit (git commit --allow-empty -m "Trigger Build") or rebase to continue.

@reidbaker reidbaker requested a review from gmackall April 13, 2026 18:47
val name = requireNotNull(plugin["name"] as? String) { "Missing valid \"name\" property for plugin object: $plugin" }
val pluginProject = project.rootProject.findProject(":$name")
if (pluginProject != null) {
val androidExtensionWrapper =
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be pluginAndroidExtension and the existing extension be projectAndroidExtension ? The current naming makes it seem like one is a wrapper and one is the direct object

but these are just actually both the direct object right, just for the different projects

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD platform-android Android applications specifically tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[AGP 9] Migrate detectLowCompileSdkVersionOrNdkVersion from project.afterEvaluate

3 participants