Search code examples
flutterdartgradle

Gradle error while running app in flutter


I was writing my code and didn't touch any files of the project. Then i wanted to start the app again and it shows me this error : ' FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all files for configuration ':classpath'.
   > Could not find com.android.tools.build:gradle:8.2.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/8.2/gradle-8.2.pom
       - https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/8.2/gradle-8.2.pom
     Required by:
         project : '

I tried many solutions in many websites but it didn't work.


Solution

  • try this in Main project gradle file

    dependencies {
          classpath 'com.android.tools.build:gradle:7.2.2'
    }
    

    put this line in gradle-wrapper-properties

    distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip