4

while starting a flutter application on vs code i am getting the following errors.

Launching lib\main.dart on RMX1801 in debug mode... Exception in thread "main" java.lang.RuntimeException: Timeout of 120000 reached waiting for exclusive access to file: C:\Users\sanjay.gradle\wrapper\dists\gradle-5.6.2-all\9st6wgf78h16so49nn74lgtbb\gradle-5.6.2-all.zip at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:61) at org.gradle.wrapper.Install.createDist(Install.java:48) at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:128) at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61) [!] Gradle threw an error while trying to update itself. Retrying the update... Exception in thread "main" java.lang.RuntimeException: Timeout of 120000 reached waiting for exclusive access to file: C:\Users\sanjay.gradle\wrapper\dists\gradle-5.6.2-all\9st6wgf78h16so49nn74lgtbb\gradle-5.6.2-all.zip at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:61) at org.gradle.wrapper.Install.createDist(Install.java:48) at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:128) at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61) [!] Gradle threw an error while trying to update itself. Retrying the update... Gradle task assembleDebug failed with exit code 1 Exited (sigterm)

I am not getting why this is occurring . What can be the reason for this and how can this be solved?

3
  • 2
    from github issues seems like a slow internet connection,you can find the issues at github.com/flutter/flutter/issues/45037
    – griffins
    Dec 13, 2019 at 11:53
  • Hi, if my answer solve your issue can you pls mark it as correct? tks! Mar 28, 2020 at 20:55
  • closed the project and restarted it, error gone. I guess it because of slow internet
    – samin
    Jan 13, 2022 at 7:05

7 Answers 7

23

It is caused by the Gradle distribution version used. To fix this, either downgrade your Gradle version to the previous or upgrade it to the next stable one. These are the Gradle distribution versions available.

Go to

android / gradle / wrapper / gradle-wrapper.properties

and replace the current Gradle version this (or choose another from Gradle distribution)

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

screenshot

I upgraded my Gradle version from 5.6.2 to 6.0.1, and it works fine with me.

2

I was also experiencing a similar problem. The following worked for me !

C:\Users\uejaz.gradle\wrapper\dists\gradle-5.6.2-all\9st6wgf78h16so49nn74lgtbb Move to this directory and delete gradle-5.6.2-all.zip and gradle-5.6.2 folder

Goto https://downloads.gradle-dn.com/distributions/gradle-5.6.2-all.zip and download the zip file Replace the .zip file with the one you had deleted earlier and extract the folder "gradle-5.6.2" in the same directory. I hope it will solve all your gradle-related problems.

Note: if your gradle version is different than mine, just change the version in the link provided above to download your gradle version.

1
  • Same as @usama one thing that really worked for me is to go to Android folder -> gradle.build and change gradle version there
    – daddy_
    Jan 7, 2020 at 10:03
2

For VS Code. if All answers are not working. do this.

I was finally able to solve the problem. The problem is with the gradle and low internet bandwidth. Just delete the C:\Users\USERNAME.gradle\wrapper\dists\gradle-5.6.2-all and download it manually from [https://downloads.gradle-dn.com/distributions/gradle-5.6.2-all.zip] or delete the old gradle files and let them download manually by using flutter run Be sure to check your gradle version before proceeding.

1
  • Somehow i am not able to delete gradle as it says some apps are using it. Can u please look into that?
    – daddy_
    Jul 1, 2020 at 10:14
1

I solved this error by upgrading the Gradle version.

Just go to:

android > grader\wrapper > Gradle-wrapper.properties

and then replace the current Gradle version to the new one:

distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip


You can see the Gradle versions in this page: https://gradle.org/releases

1

The steps worked for me are as follows

  1. Go to wrapper file in android
  2. Delete 'gradle' file inside wrapper file
  3. Then delete 'gradlew' file
  4. Go to 'gradle-wrapper.properties'
  5. Replace distributionUrl with belo link https://services.gradle.org/distributions/gradle-6.4.1-all.zip
  6. Exit from android studio and re-open

Hope this would be useful

0

Open the flutter projects's android directory from Android Studio . It will automatically shows you to delete old gradle version and update to current version.

0
  1. Open terminal
  2. Go to project directory
  3. Run Below command

flutter clean

flutter pub get

flutter run

This solved my problem.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.