'Gradle threw an error while downloading artifacts from the network .. Exception: Gradle task assembleDebug failed with exit code 1

I just started with app development with flutter, but am not even able to run the test app. This is what come on console :

Launching lib/main.dart on AOSP on IA Emulator in debug mode... Running Gradle task 'assembleDebug'... Exception in thread "main" java.util.zip.ZipException: error in opening zip file at java.util.zip.ZipFile.open(Native Method) at java.util.zip.ZipFile.(ZipFile.java:225) at java.util.zip.ZipFile.(ZipFile.java:155) at java.util.zip.ZipFile.(ZipFile.java:169) at org.gradle.wrapper.Install.unzip(Install.java:214) at org.gradle.wrapper.Install.access$600(Install.java:27) at org.gradle.wrapper.Install$1.call(Install.java:74) at org.gradle.wrapper.Install$1.call(Install.java:48) at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65) 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...

I have active Internet connection. I also downloaded the gradle 6.4.1 and extracted it in android-studio >> plugins, This what is been shown on gradle-wrapper.properties :

distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=https://services.gradle.org/distributions/gradle-5.6.2-all.zip*

I use Ubuntu 18.04.

Solution 1:[1]

Do follow some steps:

  1. Go to flutter_app => android => gradle => wrapper directory
  2. Delete gradle-wrapper.jar file
  3. Open and edit gradle-wrapper.properties file
  4. Change distributionUrl=https://services.gradle.org/distributions/gradle-x.x.x-all.zip to gradle-7.2-all.zip or latest
  5. On terminal use flutter run command

I solved my issue, hopefully yours

Solution 2:[2]

I am running macOS so Before Flutter build I added sudo flutter build which make download Gradle 6 works

Solution 3:[3]

The error is related to Gradle, this is usually due to corrupt or incomplete Gradle setup Go to the root directory and locate the hidden .gradle folder and delete it. For mac, open the terminal and execute

cd ~ rm -rf .gradle

Solution 4:[4]

In my case i opened build.gradle and updated all libraries to the latest version by using android studio. you can also check this link

Solution 5:[5]

open the android directory and delete the entire gradle folder and make sure your internet connection is stable and run your app again. it is to be note that the gradlew file is corrupted hence causing this error.

if this doesn't work then try deleting the .gradle folder in your users directory by going to C:\Users\username\ to delete the .gradle folder and re download on opening android studio again. a network interruption during download of gradle can cause this type of error.

Solution 6:[6]

I cloned a repository so they were using a higher grade version than the one in my computer, so I went to my gradle-wrapper.properties file and reduced it to the version in my computer then ran the app.

Solution 7:[7]

I just downloaded and installed the latest version of android studio. When I reopened the same project in the updated version, I got a notification to upgrade my gradle. I clicked the upgrade button and everything works now.

Solution 8:[8]

First, make sure to update all your packages in your pubspec. For me, connectivity_widget was the problem.

Solution 9:[9]

I literally had given a rage quit, turned off the computer and went to sleep, the other day I opened android studio, waited for gradle.sync (which by the way took more than 10min) and when doing the build it worked. It's probably not the correct solution, but it worked for me.

Solution 10:[10]

[!] Gradle threw an error while downloading artifacts from the network.Retrying to download... Exception: Gradle task assembleDebug failed with exit code 1

in my flutter project ------->

I solved it by removing -> firebase_storage: ^0.3.0 this from pubspec.ymal

Solution 11:[11]

I spent an entire day working out all the possible solutions on the internet. Turns out I just needed to switch my network connection from college wifi to my mobile data. I still don't know why but it worked. If anyone know why, please let me know