Skip to content

Flutter Analyze --suggestions does not skip comment lines in settings.gradle #172055

@leocirto

Description

@leocirto

Steps to reproduce

In the file app/android/settings.gradle.kts, add some comments in the plugins section (must be more than 1 line).

For example:

plugins {
    id("dev.flutter.flutter-plugin-loader") version "1.0.0"
 // PREVIOUS AGP VERSION:
 // id "com.android.application"  version "0.0.0" apply false // <-- THIS VERSION IS PICKED BY flutter analyze
 // CURRENT AGP VERSION:
    id("com.android.application") version "8.7.3" apply false
    id("org.jetbrains.kotlin.android") version "2.1.0" apply false
}

Run flutter analyze.
Note that the analyzer returns the AGP version in the commented line:

flutter analyze --suggestions -v | grep gradle
[  +42 ms] LocalFile: '/app/android/build.gradle.kts' doesn't provide an AGP version. Checking settings.
[   +7 ms] LocalFile: '/app/android/settings.gradle.kts' provides AGP version: 0.0.0
           │ #1      getGradleVersionFor (package:flutter_tools/src/android/gradle_utils.dart:707:3)         │

Expected results

Commented lines should be skipped by the analyzer:

flutter analyze --suggestions -v | grep gradle
[  +40 ms] LocalFile: '/app/android/build.gradle.kts' doesn't provide an AGP version. Checking settings.
[  +18 ms] LocalFile: '/app/android/settings.gradle.kts' provides AGP version: 8.7.3
           │ [✓] Java/Gradle/Android Gradle Plugin: compatible java/gradle/agp │

Actual results

(see above)

Code sample

Code sample
[Paste your code here]

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
flutter doctor -v
[✓] Flutter (Channel stable, 3.32.0, on openSUSE Tumbleweed 6.14.6-1-default, locale en_US.UTF-8)
    • Flutter version 3.32.0 on channel stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision be698c48a6 (8 weeks ago), 2025-05-19 12:59:14 -0700
    • Engine revision 1881800949
    • Dart version 3.8.0
    • DevTools version 2.45.1

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.1)
    • Platform android-35, build-tools 35.0.1
    • Java version OpenJDK Runtime Environment (build 21.0.6+-13368085-b895.109)

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listfound in release: 3.32Found to occur in 3.32found in release: 3.33Found to occur in 3.33has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-androidAndroid applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-androidOwned by Android platform teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-androidTriaged by Android platform team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions