Skip to content

Commit f5bf32d

Browse files
authored
[CP-Stable] Ensure Warnings Do Not Log When AGP Is Below 9 (flutter#188716)
This was a manual cherry pick of flutter#188373. ### Issue Link: What is the link to the issue this cherry-pick is addressing? flutter#188718 ### Impact Description: What is the impact (ex. visual jank on Samsung phones, app crash, cannot ship an iOS app)? Does it impact development (ex. flutter doctor crashes when Android Studio is installed), or the shipping of production apps (the app crashes on launch). This information is for domain experts and release engineers to understand the consequences of saying yes or no to the cherry pick. All existing Flutter Android apps and add-to-app scenarios that use AGP < 9 and apply KGP. ### Changelog Description: Explain this cherry pick: * In one line that is accessible to most Flutter developers. * That describes the state prior to the fix. * That includes which platforms are impacted. See [best practices](https://github.com/flutter/flutter/blob/main/docs/releases/Hotfix-Documentation-Best-Practices.md) for examples. < Replace with changelog description here > [flutter/188718](flutter#186100): When building Flutter Android apps and add-to-app modules using AGP < 9 with KGP, the tool incorrectly logs Built-in Kotlin migration warnings. ### Workaround: Is there a workaround for this issue? This change must be made. Built-in Kotlin only exists starting AGP 9, therefore we should not be informing app developers to migrate when their apps are below AGP 9. ### 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: What are the steps to validate that this fix works? - navigate to plugin camera_android_camerax in the packages repo - change versions to AGP: 8.11.1, Gradle: 8.14, KGP: 2.2.20 in settings.gradle.kts - add KGP id("kotlin-android") to the example app build.gradle.kts and the plugin module's build.gradle.kts - `flutter build apk` and the build is successful and you see no logs. Without this change, you will see logs both for app developers and for plugin authors.
1 parent c63e437 commit f5bf32d

3 files changed

Lines changed: 475 additions & 520 deletions

File tree

packages/flutter_tools/gradle/src/main/kotlin/FlutterPluginUtils.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,11 @@ object FlutterPluginUtils {
656656
}
657657

658658
project.gradle.projectsEvaluated {
659+
// Safe to query AGP version after all projects are evaluated.
660+
val agpVersion = VersionFetcher.getAGPVersion(project)
661+
if (agpVersion == null || agpVersion.major < 9) {
662+
return@projectsEvaluated
663+
}
659664
if (shouldLogForApp) {
660665
project.logger.error(
661666
"""

0 commit comments

Comments
 (0)