skip to Main Content

I’m unable to build and run my flutter project. Every time I run the project it gives me this error

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().

I searched and tried the following solution but nothing has worked so far:

  1. Clean & Build Project
  2. Deleted .gradle & .dart_tools folder
  3. Downgraded Gradle version

I’m using Android studio 4.2.1. Let me know if you need anything else. Thanks in advance!

2

Answers


  1. Chosen as BEST ANSWER

    I tried many solutions but the following worked for me:

    1. Downgraded flutter version from 2.2.3 to 2.2.2
    2. Deleted ~/.android folder and then run the flutter project. Everything worked just fine.

  2. I am use Flutter 2.5, same issue.

    set ./android/build.gradle file to newer version:

    classpath ‘com.android.tools.build:gradle:7.0.0’

    buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        google()
        mavenCentral()
    }
    
    dependencies {
        classpath 'com.android.tools.build:gradle:7.0.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
    

    }

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