Flutter Exception in thread "main" java.util.zip.ZipException: zip END header not found - flutter

I am facing such error after running flutter run command
Exception in thread "main" java.util.zip.ZipException: zip END header not found
at java.base/java.util.zip.ZipFile$Source.zerror(ZipFile.java:1607)
at java.base/java.util.zip.ZipFile$Source.findEND(ZipFile.java:1497)
at java.base/java.util.zip.ZipFile$Source.initCEN(ZipFile.java:1504)
at java.base/java.util.zip.ZipFile$Source.<init>(ZipFile.java:1308)
at java.base/java.util.zip.ZipFile$Source.get(ZipFile.java:1271)
at java.base/java.util.zip.ZipFile$CleanableResource.<init>(ZipFile.java:733)
at java.base/java.util.zip.ZipFile$CleanableResource.get(ZipFile.java:850)
at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:248)
at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:177)
at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:191)
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'... 390,5s
Exception: Gradle task assembleDebug failed with exit code 1

The error is related to Gradle, this is usually due to corrupt or incomplete Gradle setup
find (.gradle) folder and delete it
then run the application again and wait for new gradle setup to complete

Related

CommandInvokationFailure: Gradle build failed

I am new to unity. I am using unity 2021.3.10f1 I made my own game and added advertising and other features. When trying to build, it shows the error "CommandInvokationFailure: Gradle build failed." Can you help? An error that is shown in unity:
CommandInvokationFailure: Gradle build failed.
D:\HappyWin\Unity and projects\2021.3.10f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath "D:\HappyWin\gradle-6.1.1\lib\gradle-launcher-6.1.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleRelease"
stderr[
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':launcher:lintVitalRelease'.
> This project uses AndroidX dependencies, but the 'android.useAndroidX' property is not enabled. Set this property to true in the gradle.properties file and retry.
The following AndroidX dependencies are detected: androidx.fragment:fragment:1.0.0, androidx.slidingpanelayout:slidingpanelayout:1.0.0, androidx.versionedparcelable:versionedparcelable:1.1.0, androidx.core:core:1.2.0, androidx.customview:customview:1.0.0, androidx.swiperefreshlayout:swiperefreshlayout:1.0.0, androidx.interpolator:interpolator:1.0.0, androidx.loader:loader:1.0.0, androidx.drawerlayout:drawerlayout:1.0.0, androidx.viewpager:viewpager:1.0.0, androidx.collection:collection:1.0.0, androidx.localbroadcastmanager:localbroadcastmanager:1.0.0, androidx.lifecycle:lifecycle-common:2.0.0, androidx.arch.core:core-common:2.0.0, androidx.annotation:annotation:1.2.0, androidx.startup:startup-runtime:1.0.0, androidx.tracing:tracing:1.0.0, androidx.legacy:legacy-support-core-ui:1.0.0, androidx.lifecycle:lifecycle-livedata:2.0.0, androidx.lifecycle:lifecycle-viewmodel:2.0.0, androidx.lifecycle:lifecycle-livedata-core:2.0.0, androidx.arch.core:core-runtime:2.0.0, androidx.legacy:legacy-support-core-utils:1.0.0, androidx.documentfile:documentfile:1.0.0, androidx.cursoradapter:cursoradapter:1.0.0, androidx.lifecycle:lifecycle-runtime:2.0.0, androidx.coordinatorlayout:coordinatorlayout:1.0.0, androidx.asynclayoutinflater:asynclayoutinflater:1.0.0, androidx.print:print:1.0.0
Changed gradle to different versions. Did not help.

flutter Gradle task Assemble Debug failed

Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain
Caused by: java.lang.ClassNotFoundException: org.gradle.wrapper.GradleWrapperMain
Exception: Gradle task assembleDebug failed with exit code 1
any help ??
in case someone has the same problem
the problem was with the directory of the project
It was in my main folder which has non English characters

cannot compile unity project

CommandInvokationFailure: Gradle build failed.
C:\Program Files\Java\jdk1.8.0_192\bin\java.exe -classpath "C:\Program Files\Unity\Hub\Editor\2018.2.9f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-4.10.2.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx2048m" "assembleRelease"
stderr[
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':lintVitalRelease'.
Could not resolve all files for configuration ':lintClassPath'.
Could not find org.codehaus.groovy:groovy-all:2.4.12.
Searched in the following locations:
file:/C:/d/programs/android sdk/extras/m2repository/org/codehaus/groovy/groovy-all/2.4.12/groovy-all-2.4.12.pom
file:/C:/d/programs/android sdk/extras/m2repository/org/codehaus/groovy/groovy-all/2.4.12/groovy-all-2.4.12.jar
file:/C:/d/programs/android sdk/extras/google/m2repository/org/codehaus/groovy/groovy-all/2.4.12/groovy-all-2.4.12.pom
file:/C:/d/programs/android sdk/extras/google/m2repository/org/codehaus/groovy/groovy-all/2.4.12/groovy-all-2.4.12.jar
… and more...

Gradle can't fetch dependencies when setting up a Unity project

I am getting this error while setting up unity project for android
Gradle failed to fetch dependencies.
(Note: this error log is redacted. See the screenshot above for more info)
Gradle failed to fetch dependencies.
stderr: Exception in thread "main" java.util.zip.ZipException: zip END header not found
at java.base/java.util.zip.ZipFile$Source.zerror(ZipFile.java:1252)
at java.base/java.util.zip.ZipFile$Source.findEND(ZipFile.java:1153)
at java.base/java.util.zip.ZipFile$Source.initCEN(ZipFile.java:1160)
at java.base/java.util.zip.ZipFile$Source.<init>(ZipFile.java:997)
at java.base/java.util.zip.ZipFile$Source.get(ZipFile.java:960)
at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:216)
at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:148)
at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:162)
at org.gradle.wrapper.Install.unzip(Install.java:215)
at org.gradle.wrapper.Install.access$600(Install.java:27)
at org.gradle.wrapper.Install$1.call(Install.java:75)
at org.gradle.wrapper.Install$1.call(Install.java:48)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:69)
at org.gradle.wrapper.Install.createDist(Install.java:48)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:107)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
exit code: 1
UnityEngine.Debug:LogError(Object) Google.Logger:Log(String, LogLevel)
GooglePlayServices.PlayServicesResolver:Log(String, LogLevel)
GooglePlayServices.<GradleResolution>c__AnonStorey14:<>m__1F(Result)
GooglePlayServices.<GradleResolution>c__AnonStorey15:<>m__28()
GooglePlayServices.PlayServicesResolver:PumpUpdateQueue()
UnityEditor.EditorApplication:Internal_CallUpdateFunctions()

Android duplicate dependencies error - Annotation

when I was building my projecti I get some errors like this
Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/fasterxml/jackson/annotation/JacksonAnnotation.class
How can I resolve this problem?