Flutter throwing error, Timeout of X reached waiting for exclusive access to file: Gradle
Asked Answered
U

4

7
Launching lib\main.dart on SM G615F in debug mode...
lib\main.dart:1
Exception in thread "main" java.lang.RuntimeException: Timeout of 120000 reached waiting for exclusive access to file: C:\Users\Me\.gradle\wrapper\dists\gradle-6.7-all\cuy9mc7upwgwgeb72wkcrupxe\gradle-6.7-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 downloading artifacts from the network. Retrying to download...
Exception in thread "main" java.lang.RuntimeException: Timeout of 120000 reached waiting for exclusive access to file: C:\Users\Shaad\.gradle\wrapper\dists\gradle-6.7-all\cuy9mc7upwgwgeb72wkcrupxe\gradle-6.7-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 downloading artifacts from the network. Retrying to download...
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

Can You help me Fight this issue? I am Getting Gradle task assembleDebug error, also When I Run Flutter on Physical Device it Takes so much time to run and execute.

I want to seek help in this.

Untruthful answered 13/4, 2021 at 9:35 Comment(0)
L
21

This could be caused by broken gradle installation or slow internet.

Solution:

Delete the .gradle folder located at Windows: C:\Users\<user>\.gradle or Mac: /home/<user>/.gradle

and then run the flutter app again.

It might take a little longer because gradle dependencies will be downloaded again. Don't disconnect your device.

Liripipe answered 13/4, 2021 at 10:11 Comment(2)
This is correct answer for question and needs to be marked as answer. I had same problem and it solved it! – Maturation
If deleting the .gradle folder doesn't work for everyone. You can try switching to your mobile data and try running the application. It worked for me, you can find the reference here. – Domoniquedomph
C
7

This is how to fix this.

  • Just delete the .gradle folder in your user directory
  • The command in linux or MacOS is rm -r $HOME/.gradle/
  • Then open your project directory and then navigate to android folder
  • Finally, run ./gradlew
  • This will force gralde to redownload all dependencies needed
  • That's it ,

Happy coding βœ¨πŸŽ‰πŸŽ‰πŸŽ‰

Chiropody answered 4/4, 2023 at 21:50 Comment(0)
C
0

Try to install gradle manually (https://services.gradle.org/distributions/gradle-4.6-bin.zip), and unzip it

Open <path_to_flutter_app>/android/gradlew

Find: CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar and replace with: CLASSPATH=<path_to_downloaded_gardle>/gradle-4.6/lib/gradle-launcher-4.6.jar

Find: exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"

and replace with: exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.launcher.GradleMain "$@"

flutter run

Catchword answered 8/7, 2023 at 11:41 Comment(0)
H
0

A gradle process could be holding a file handle in the .gradle folder. What worked for me is killing all java processes.

Hoahoactzin answered 28/5, 2024 at 13:17 Comment(0)

© 2022 - 2025 β€” McMap. All rights reserved.