skip to Main Content

I am trying to run flutter run command but it is giving me this error why ??

I am trying to do everything i even change grade file also but then also it is not working.

flutter run --android-skip-build-dependency-validation
Launching lib/main.dart on Android SDK built for arm64 in debug mode...

FAILURE: Build failed with an exception.

* Where:
Settings file '/Users/nidhigodhani/Downloads/flutter_realtime_object_detection/android/settings.gradle' line: 21

* What went wrong:
Plugin [id: 'com.android.application', version: '{agpVersion}', apply: false] 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 (could not resolve plugin artifact 'com.android.application:com.android.application.gradle.plugin:{agpVersi
on}')                                                                                                                              Searched in the following repositories:
    Google
    MavenRepo
    Gradle Central Plugin Repository

* 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 2s
Running Gradle task 'assembleDebug'...                           2,862ms
Error: Gradle task assembleDebug failed with exit code 1

I want answer of this

2

Answers


  1. Update Gradle: Ensure you’re using the latest compatible version of Gradle. You can check the documentation for the Flutter version you’re using for recommended Gradle versions.

    Check settings.gradle: Open the android/settings.gradle file and look for the line mentioned in the error (line 21). If the plugin declaration is missing, add the following line:

    pluginManagement {
          repositories {
            gradleCentral()
            google()
          }
        }
    

    Verify Plugin Version: Check the Flutter documentation or release notes for the appropriate version of the com.android.application plugin for your Flutter version. Replace {agpVersion} with the correct version number in the settings.gradle file (7.3.0).

    Here’s an example of a complete settings.gradle file with the plugin declaration:

    pluginManagement {
      repositories {
        gradleCentral()
        google()
      }
    }
    

    Additional Tips:

    After making changes to Gradle files, run flutter clean followed by flutter pub get to ensure a clean build and download any necessary dependencies.
    Refer to the official Flutter documentation for detailed instructions on managing dependencies and Gradle configuration:
    https://docs.flutter.dev/packages-and-plugins/using-packages

    By following these steps and referencing the documentation, you should be able to resolve the missing plugin issue and successfully build your Flutter project for Android.

    Login or Signup to reply.
  2. From this line:

    Plugin [id: 'com.android.application', version: '{agpVersion}', apply: false]
    

    It looks like the agpVersion variable is not defined and therefore the Gradle cannot find it.

    Define your version directly, like this:

    Plugin [id: 'com.android.application', version: '7.3.0', apply: false]
    

    Note: You should specify a compatible AGP version here according to your Gradle version.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search