1

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.

James Z
  • 12,209
  • 10
  • 24
  • 44
  • 1
    "flutter clean" run this again, then restart ur device. if this doesn't fix then , change the gradle-version to old. In build.gradle--> buildscript { ext.kotlin_version = '1.7.10' classpath 'com.android.tools.build:gradle:7.1.2'}. & in gradle-wrapper.properties-->distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip – JB Jason Apr 22 '23 at 04:22
  • 1
    Hey @JBJason, thanks a bunch! The app's working fine, but the "android" folder still has two errors showing in red. If you happen to know anything about these errors, I'd really appreciate your help! Thanks again for your assistance. – Rayyaan Malik Apr 23 '23 at 17:57

0 Answers0