Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execution Failed for task ':gradle:compileGroovy'

When I create a new flutter project the project always failed to run and output the exception that shown in the below

I tried to delete the folder .gradle and rerun the project but I get the same problem how can I solve this problem? Launching lib\main.dart on sdk gphone64 x86 64 in debug mode... Running Gradle task 'assembleDebug'... FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':gradle:compileGroovy'.

Could not resolve all files for configuration ':gradle:detachedConfiguration1'. Could not find org.codehaus.groovy:groovy:?.?.??. Searched in the following locations: - https://dl.google.com/dl/android/maven2/org/codehaus/groovy/groovy/?.?.??/groovy-?.?.??.pom - https://repo.maven.apache.org/maven2/org/codehaus/groovy/groovy/?.?.??/groovy-?.?.??.pom Required by: project :gradle Could not find org.codehaus.groovy:groovy-ant:?.?.??. Searched in the following locations: - https://dl.google.com/dl/android/maven2/org/codehaus/groovy/groovy-ant/?.?.??/groovy-ant-?.?.??.pom - https://repo.maven.apache.org/maven2/org/codehaus/groovy/groovy-ant/?.?.??/groovy-ant-?.?.??.pom Required by: project :gradle Could not find org.codehaus.groovy:groovy-astbuilder:?.?.??. Searched in the following locations: - https://dl.google.com/dl/android/maven2/org/codehaus/groovy/groovy-astbuilder/?.?.??/groovy-astbuilder-?.?.??.pom - https://repo.maven.apache.org/maven2/org/codehaus/groovy/groovy-astbuilder/?.?.??/groovy-astbuilder-?.?.??.pom Required by: project :gradle

  • 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 4s Exception: Gradle task assembleDebug failed with exit code 1 The Flutter CLI developer tool uses Google Analytics to report usage and diagnostic data along with package dependencies, and crash reporting to send basic crash reports. This data is used to help improve the Dart platform, Flutter framework, and related tools. Telemetry is not sent on the very first run. To disable reporting of telemetry, run this terminal command: flutter --disable-telemetry. If you opt out of telemetry, an opt-out event will be sent, and then no further information will be sent. This data is collected in accordance with the Google Privacy Policy . Please note that analytics reporting was already disabled, and will continue to be disabled.

This is the exception in debug console

like image 216
MHD Rajab Alkahef Avatar asked Jul 10 '26 09:07

MHD Rajab Alkahef


2 Answers

  1. Find out your java version by running the command:

    java --version

  2. Go to https://docs.gradle.org/current/userguide/compatibility.html#java and find out the gradle version compatible with your java version. mine was 19.0.2 so the matching one is 7.6

  3. Go to your project folder and find the file, gradle-wrapper.properties in: android/gradle/wrapper/gradle-wrapper.properties

  4. Change the version number of the distribution Url

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

    to: distributionUrl=https://services.gradle.org/distributions/gradle-7.6- all.zip

  5. Rerun the project, gradle should begin downloading a new version. It took a while but it worked for me.

Ps. I tried the approach on the flutter website to upgrade gradle but the command didn't work I guess because the gradle version was incompatible with the Java installed.

like image 140
Jamal-o Avatar answered Jul 14 '26 14:07

Jamal-o


This problem because of the new version of Flutter 3.13. I faced this problem and there is a solution:

  1. Download the previous version for Flutter, like 3.10
  2. Delete your .gradle from your system disk at the path of the folder, like: `C:\Users<your user name>’
  3. Rerun the project again

If this doesn't work, do this with the previous steps:

  1. Make your system in ENGLISH if the system is in another language
  2. Make sure the path of Flutter that you added to the environment variable is in Lowercase and doesn’t have any symbols; here is an example how it should to be: C:\development\flutter\bin

Notice: If the path has any Uppercase or custom symbols, you have to edit the name of the folders in your Windows Explorer, then add the path to environment variable.

  1. Make sure your Regional Format in US from: Settings -> Time & Language -> Region -> Regional Format

  2. delete your .gradle from your system disk the path of the folder like: C:\Users'your user name

  3. Rerun the project again

like image 36
abdalmalek ak Avatar answered Jul 14 '26 15:07

abdalmalek ak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!