Flutter and gradle problem

Good evening,
I am a biggner using flutter and dart and trying to run application in course but i found the below respond, can anybody help:


Launching lib\main.dart on sdk gphone64 x86 64 in debug mode...
Running Gradle task 'assembleDebug'...
You are applying Flutter's app_plugin_loader Gradle plugin imperatively using the apply script method, which is deprecated and will be removed in a future release. Migrate to applying Gradle plugins with the declarative plugins block: https://flutter.dev/go/flutter-gradle-plugin-apply


FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\mhasa\StudioProjects\untitled2\android\app\build.gradle' line: 2

* What went wrong:
Plugin [id: 'com.android.application'] was not found in any of the following sources:

- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Included Builds (None of the included builds contain this plugin)
- Plugin Repositories (plugin dependency must include a version number for this source)

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
Error: Gradle task assembleDebug failed with exit code 1

The error is telling you, that you try to apply the plugin with ID com.android.application, without specification a version.

so can you please specify the solution if you know how…
Thanks

I have no idea about Flutter and whether there is something special to it. But well, as I said, Gradle complains you didn’t specify a version, so probably specify a version?

I believe your problem is that you have not included a repositories section in your pluginManagement block in settings.gradle.

The instructions for migrating from a script apply to a proper gradle plugin can be found here.

Specifically make sure your settings.gradle (or settings.gradle.kts) looks something like

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
    }
    settings.ext.flutterSdkPath = flutterSdkPath()

    includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle")

    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }
}

plugins {
    id "dev.flutter.flutter-gradle-plugin" version "1.0.0" apply false
    id "com.android.application" version "<YOUR AGP VERSION>" apply false
    id "org.jetbrains.kotlin.android" version "<YOUR KOTLIN VERSION>" apply false
}

include ":app"