gpt4 book ai didi

android - 项目构建期间出现 ZipException

转载 作者:行者123 更新时间:2023-12-02 20:30:55 28 4
gpt4 key购买 nike

我正在更新版本 3.4 的 Android studio 和插件(版本 5.1.1 的 gradle)当我尝试构建项目时,出现错误

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

我下载了 gradle-5.1.1-all.zip 并尝试替换现有的,但没有成功。

有什么想法导致此错误吗?

日志

    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)

构建工具28.0.3

最佳答案

此问题的原因之一是 decommissioning of HTTP services by Gradle 。这意味着,如果您的 [PROJECT_PATH]/gradle/wrapper/gradle-wrapper.properties 文件包含如下条目:

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

...那么此条目将尝试从无法通过 http 访问的服务中检索 ZIP 文件,并且它将默默返回一个空的 ZIP 文件;因此,这将成为尝试解压缩该空 ZIP 文件的任何进程的错误来源。

要解决此问题,只需更改 [PROJECT_PATH]/gradle/wrapper/gradle-wrapper.properties 文件,使其 distributionUrl 条目使用 https:

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

希望这有帮助。

关于android - 项目构建期间出现 ZipException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55765492/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com