Exception: Gradle task assembleDebug failed with exit code 1. Could not find com.android.tools.build:gradle:8.1.0

742 Views Asked by At

So, I just started working on a new Flutter app, and also just installed gradle version 8.1, but as soon as I opened my project in vscode, I saw a couple of errors in the "android" folder. First is this one (in app/build.gradle):

unable to resolve class GradleException @ line 11, column 15.Gradle

In app/build.gradle

enter image description here

However, this one was not effecting anything when I run the app. Only the "GradleException" was highlighted.

The second one:

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.1.0.
     Searched in the following locations:     
https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/8.1.0/gradle-8.1.0.pom
       https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/8.1.0/gradle-8.1.0.pom
     Required by:
         project :

* 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
Exception: Gradle task assembleDebug failed with exit code 1

These are some snippets of the two gradle files:

In build.gradle

enter image description here

In gradle-wrapper.properties

enter image description here

It seems like it's some gradle version compatibility issues or maybe something else.

I have tried various things such as, deleting the .gradle folder and running "flutter run", "flutter clean", "flutter build apk", I have even tried changing the versions of gradle in their respective fles as shown in the above code snippets, etc. However nothing seemed to be working. I don't know what version of gradle is compatible with what version of flutter SDK (its up to date BTW), or things like that.

0

There are 0 best solutions below