Home > database >  My flutter project broke and I get this gradle error
My flutter project broke and I get this gradle error

Time:04-14

FAILURE: Build failed with an exception.

* What went wrong:
Could not create an instance of type org.gradle.invocation.DefaultGradle.
> Could not configure services using GradleScopeCompileServices.configure().

* 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

This is my build.gradle

buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.google.gms:google-services:4.3.10'
        classpath 'com.android.tools.build:gradle:7.1.3'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

I tried so many things I changed flutter and gradle version and looked everywhere but I still get this error. It worked before now it just doesen't. Btw java version is set to 1.8

CodePudding user response:

Faced the same issue.

Solution:

  1. Downgrade flutter version from 2.2.3 to 2.2.2
  2. Delete ~/.android folder.
  3. Restart android studio.

CodePudding user response:

that kind of error has like a hundreds reason no one can know except to remember what you had done b4 .. but anyway for better solution follow the following

  • go to tools tab then flutter clean

  • go to file tab then invalidate cashe and restart

  • follow the awesome steps in this link to have the latest updates from gradle https://medium.com/@gtxgat/upgrade-gradle-version-professionally-in-flutter-5e0c16305cc0

  • finally go to android folder then build gradle then on top right you will see edit file or something similar .. press on it and open new window and let it auto update till the end .. and better if you go to file into that new window then select project structure and manually see what the warning will it show to you and only press update

and yeah don't forget to use the latest flutter sdk

you will have the best experience inshallah

  • Related