Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ZipException during project build

I'm updating Android studio and plugin for version 3.4 (gradle for version 5.1.1) When I try build project, I get an error

java.util.zip.ZipException: zip file is empty

I download gradle-5.1.1-all.zip and tried replace existing but it was unsuccessfully.

Any ideas what cause this error?

log

    Caused by: org.gradle.api.tasks.TaskExecutionException: Execution     failed for task ':app:transformClassesWithDexBuilderForDevDebug'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:95)
    at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:91)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:57)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:119)
    at org.gradle.api.internal.tasks.execution.ResolvePreviousStateExecuter.execute(ResolvePreviousStateExecuter.java:43)
    at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:93)

    *****

    ... 6 more
Caused by: java.lang.RuntimeException: com.android.build.api.transform.TransformException: java.util.zip.ZipException: zip file is empty
    at com.android.builder.profile.Recorder$Block.handleException(Recorder.java:55)
    at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:104)
    at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:230)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

    *****

Caused by: com.android.build.api.transform.TransformException: java.util.zip.ZipException: zip file is empty
    at com.android.build.gradle.internal.transforms.DexArchiveBuilderTransform.transform(DexArchiveBuilderTransform.java:442)
    at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:239)
    at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:235)
    at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102)
    ... 77 more
Caused by: java.util.zip.ZipException: zip file is empty
    at java.util.zip.ZipFile.open(Native Method)
    at java.util.zip.ZipFile.<init>(ZipFile.java:219)
    at java.util.zip.ZipFile.<init>(ZipFile.java:273)
    at com.android.tools.r8.ArchiveClassFileProvider.<init>(ArchiveClassFileProvider.java:63)
    at com.android.tools.r8.ArchiveClassFileProvider.<init>(ArchiveClassFileProvider.java:50)
    at com.android.builder.dexing.r8.CachingArchiveClassFileProvider.<init>(CachingArchiveClassFileProvider.java:32)
    at com.android.builder.dexing.r8.ClassFileProviderFactory.createProvider(ClassFileProviderFactory.java:123)
    at com.android.builder.dexing.r8.ClassFileProviderFactory.<init>(ClassFileProviderFactory.java:93)
    at com.android.build.gradle.internal.transforms.DexArchiveBuilderTransform.transform(DexArchiveBuilderTransform.java:363)

Build tools 28.0.3

like image 709
KillAndEat Avatar asked Apr 19 '19 17:04

KillAndEat


2 Answers

One of the causes of this problem is the decommissioning of HTTP services by Gradle. This means that if your [PROJECT_PATH]/gradle/wrapper/gradle-wrapper.properties file has an entry like:

distributionUrl=http\://services.gradle.org/distributions/gradle-{version}.zip

... then this entry will try to retrieve a ZIP file from a service no longer accessible through http and it will silently return an empty ZIP file; which consequentially will be the source of an error from any process trying to unzip that empty ZIP file.

To fix this, just change your [PROJECT_PATH]/gradle/wrapper/gradle-wrapper.properties file to have its distributionUrl entry to use https:

distributionUrl=https\://services.gradle.org/distributions/gradle-{version}.zip

Hope this helps.

like image 175
Marco R. Avatar answered Nov 04 '22 17:11

Marco R.


Try to recreate a gradle wrapper. It seems to me, you use old version of it. I fixed the same issues in the same way.

like image 26
Alexandr Avatar answered Nov 04 '22 18:11

Alexandr