Skip to content

The Flutter Gradle plugin's configureLegacyPluginEachProjects function problem #155484

Closed

Description

@goosetapa

https://github.com/flutter/flutter/blob/2f149da67614349cb60bc77b465ce6a533aa951e/packages/flutter_tools/gradle/src/main/groovy/flutter.groovy#L689%EC%97%90%EC%84%9C

The Flutter Gradle plugin's configureLegacyPluginEachProjects Groovy code is detecting the text content of the existing settings.gradle file, regardless of whether it is in comments or the main body.

Even if I comment out the '.flutter-plugins' string in the settings.gradle file, the Flutter Gradle plugin still recognizes that it is using the legacy settings.gradle configuration method.

As a result, during flutter build apk or flutter run command, it outputs error logs saying, "Plugin project : listed, but not found. Please fix your settings.gradle/settings.gradle.kts."

Activity

  1. added
    in triagePresently being triaged by the triage team
    platform-androidAndroid applications specifically
    toolAffects the "flutter" command-line tool. See also t: labels.
    t: gradle"flutter build" and "flutter run" on Android
    team-androidOwned by Android platform team
    and removed
    in triagePresently being triaged by the triage team
    on Sep 23, 2024
  2. reidbaker commented on Sep 23, 2024

    @reidbaker
    Contributor

    I think we just looked at the existence of the file and if both exist we use the legacy file. If I recall correctly this mirrors the behavior of other gradle plugins.

    Can you share why you want 2 different settings files so I can better understand the use case?

    @gmackall do you think we should read the contents of these files to determine which to pick? I am leaning against making that change.

  3. goosetapa commented on Sep 24, 2024

    @goosetapa
    ContributorAuthor

    I think we just looked at the existence of the file and if both exist we use the legacy file. If I recall correctly this mirrors the behavior of other gradle plugins.

    Can you share why you want 2 different settings files so I can better understand the use case?

    @gmackall do you think we should read the contents of these files to determine which to pick? I am leaning against making that change.

    Okay. I will show you 2 different settings files:

    The first one generates the error(or warning) logs during flutter build apk or flutter run command, but the last one doesn't.

    The firlst settings.gradle file:

    pluginManagement {
        def flutterSdkPath = {
            def properties = new Properties()
            file("local.properties").withInputStream { properties.load(it) }
            def flutterSdkPath = properties.getProperty("flutter.sdk")
            assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
            return flutterSdkPath
        }()
    
        println "flutterSdkPath: $flutterSdkPath"
    
        includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
    
        repositories {
            google()
            mavenCentral()
            gradlePluginPortal()
        }
    }
    
    plugins {
        id "dev.flutter.flutter-plugin-loader" version "1.0.0"
        id "com.android.application" version "8.4.0" apply false
        id "com.google.gms.google-services" version "4.3.15" apply false
        id "org.jetbrains.kotlin.android" version "1.8.22" apply false
    }
    
    include ":app"

    The second settings.gradle file:

    // include ':app'
    
    // def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
    
    // def plugins = new Properties()
    // def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')   <--- This generates error logs even if it is commented text.
    // if (pluginsFile.exists()) {
    //     pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
    // }
    
    // plugins.each { name, path ->
    //     def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
    //     include ":$name"
    //     project(":$name").projectDir = pluginDirectory
    // }
    
    pluginManagement {
        def flutterSdkPath = {
            def properties = new Properties()
            file("local.properties").withInputStream { properties.load(it) }
            def flutterSdkPath = properties.getProperty("flutter.sdk")
            assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
            return flutterSdkPath
        }()
    
        println "flutterSdkPath: $flutterSdkPath"
    
        includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
    
        repositories {
            google()
            mavenCentral()
            gradlePluginPortal()
        }
    }
    
    plugins {
        id "dev.flutter.flutter-plugin-loader" version "1.0.0"
        id "com.android.application" version "8.4.0" apply false
        id "com.google.gms.google-services" version "4.3.15" apply false
        id "org.jetbrains.kotlin.android" version "1.8.22" apply false
    }
    
    include ":app"
  4. reidbaker commented on Sep 24, 2024

    @reidbaker
    Contributor

    Ah thank for explaining. I thought you were getting caught on setting.gradle vs settings.gradle.kts. I see why you would want commented out lines ignored.

  5. added
    P2Important issues not at the top of the work list
    triaged-androidTriaged by Android platform team
    on Sep 26, 2024
  6. github-actions commented on Nov 25, 2024

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  7. locked as resolved and limited conversation to collaborators on Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listplatform-androidAndroid applications specificallyr: fixedIssue is closed as already fixed in a newer versiont: gradle"flutter build" and "flutter run" on Androidteam-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