skip to Main Content

No matter how hard I tried and looked for solutions online, none of them worked. It’s strange because my old project is running fine, but when I tried to create a new project and run a basic counter app, it kept giving me an error. It’s really frustrating when something that should be simple becomes so complicated.

[!] Gradle threw an error while downloading artifacts from the network.
Retrying Gradle Build: #4, wait time: 800ms
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.<init>(ZipFile.java:225)
        at java.util.zip.ZipFile.<init>(ZipFile.java:155)
        at java.util.zip.ZipFile.<init>(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)
Running Gradle task 'assembleDebug'...                           1,925ms

I tried to change the classpathit works in the old project!

classpath 'com.android.tools.build:gradle:7.3.0'

to

classpath 'com.android.tools.build:gradle:4.1.0'

also I tried

deleted the gradle-wrapper.jar file and run – nothing works

downgrade the distributionUrl in gradle-wrapper.properties

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

to

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

I’m running the projects in VS-code

2

Answers


  1. Chosen as BEST ANSWER

    I have no idea why my project running after changing some Android files!

    What I did!

    build.gradle

    ext.kotlin_version = '1.7.10'
    

    to

     ext.kotlin_version = '1.6.10'
    
    classpath 'com.android.tools.build:gradle:7.3.0'
    

    to

    classpath 'com.android.tools.build:gradle:4.1.0'
    

    buil.gradle in app folder

    android {
        namespace "com.example.image_picker"
        compileSdkVersion flutter.compileSdkVersion
        ndkVersion flutter.ndkVersion
    

    to

    android {
        compileSdkVersion flutter.compileSdkVersion
        ndkVersion flutter.ndkVersion
    

    gradle-wrapper.properties

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

    to

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

    every AndroidManifest.xml file

    <manifest xmlns:android="http://schemas.android.com/apk/res/android">
    

    to

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.example.flutter_profile">
    

    Now I can run the projects without errors but I have quite curious to know why my projects running after changing these many things


  2. Try using VPN.
    Connect to the VPN then run your project, it may take a while as it the first time, I would also highly recommend that you run your project on a real phone, not on emulator.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search