Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 553
Ashish Sharma Avatar asked May 24 '20 12:05

Ashish Sharma


People also ask

How do you add gradle in flutter?

open your project and then go to : File->Settings->Build, Execution, Deployment->Build Tools-> Gradle. Add the path of your Gradle in The Android Studio as shown bellow.


2 Answers

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

like image 61
Subarata Talukder Avatar answered Oct 06 '22 12:10

Subarata Talukder


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

like image 41
amorenew Avatar answered Oct 06 '22 10:10

amorenew