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

18

31

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.

Dorise answered 24/5, 2020 at 12:42 Comment(4)
Are you behind a corporate firewall?Intercostal
No i guess, how do we check it ?Dorise
Are you trying this in your company network?Intercostal
also restart your IDE may help you.Paulettapaulette
S
67

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

Scythia answered 31/7, 2020 at 7:28 Comment(3)
Flutter run requires a connected device, if you are running mac then I'm not sure whether it will download the new gradle version, instead, you can run flutter build apk just after you completed the steps aboveBeulahbeuthel
What do u mean by go to flutter_app?Amalbergas
flutter_app = folder of your applicationPaulettapaulette
M
3

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

Murcia answered 14/6, 2020 at 7:11 Comment(0)
L
2

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

Linton answered 27/12, 2021 at 13:28 Comment(0)
C
2

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.

Curfew answered 13/1, 2022 at 13:20 Comment(0)
U
1

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

Umbilicate answered 15/9, 2021 at 20:5 Comment(0)
H
0

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.

Hildredhildreth answered 23/4, 2021 at 6:43 Comment(0)
M
0

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.

Mcgruter answered 21/9, 2021 at 8:3 Comment(0)
C
0

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.

Cyano answered 29/11, 2021 at 11:53 Comment(0)
H
0

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

Hesta answered 30/11, 2021 at 14:17 Comment(0)
T
0

[!] 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

Tonnage answered 10/2, 2022 at 14:36 Comment(0)
D
0

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

Ducal answered 24/4, 2022 at 5:43 Comment(1)
your college wifi may need proxy.. but your mobile date doesn't..Symbolic
C
0

I solved this problem in my case by doing this:

  1. connect to the internet
  2. Go from your project space to => android => gradle =>wrapper => gradle-wrapper-properties

then, change this

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

to this

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

, or to gradle-#-all.zip ( latest )

Cranage answered 17/6, 2022 at 1:55 Comment(0)
D
0

If you got this problem after adding icon image, then check the image name. It should always starts with "ic_launcher" for android. Of course you can change it if you want. But make sure to change it everywhere in your code.

Dignadignified answered 31/8, 2022 at 13:52 Comment(0)
L
0

It might be a network issue, just restart your network provider, and you good to go, or follow the brilliant steps listed above.

Laird answered 26/9, 2022 at 10:13 Comment(0)
C
0

It is possible that you are on the corporate network and probably a firewall is enabled on that, which prevents some artifacts from being downloaded as the download source is blocked or filtered by the corporate firewall.

P.S change to a personal network and the issue should be resolved.

Caper answered 17/10, 2022 at 17:25 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Clump
B
0

https://mcmap.net/q/101877/-gradle-threw-an-error-while-downloading-artifacts-from-the-network-exception-gradle-task-assembledebug-failed-with-exit-code-1 described the cause well. The internet connection might be unstable but you really need to delete gradle-wrapper.jar file before retry. Hope the flutter/IDE development team can resolve this issue, for example to delete gradle-wrapper.jar file automatically, so that users will not be confused.

Barite answered 16/1, 2023 at 7:4 Comment(0)
K
0

I fixed mine by running this in command prompt:

rm -rf .gradle

Then I updated my environment variable and ran flutter clean on my project and it worked fine after that.

Kimbra answered 17/1, 2024 at 19:57 Comment(0)
M
-1

I solved this problem in my case by doing this: You Need turn off your windows virus protection.

Myasthenia answered 6/6, 2023 at 8:21 Comment(2)
Also Don't forget to check for internet connectionPodagra
What the relation with antivirus ?Kyanize

© 2022 - 2025 — McMap. All rights reserved.