在Android Studio 3.1中构建项目时“执行压缩失败”错误

时间:2017-11-09 17:58:26

标签: android android-gradle android-studio-3.0

我正在尝试在Android Studio 3.1预览版中构建https://github.com/neural-nuts/Cam2Caption,但我要么使用非常旧的build.gradle,要么就死了

Error:Execution failed for task ':Application:packageDebug'.
Execution of compression failed.

在完成项目清理或重建后会发生这种情况。 OSX,最新的一切。我使用的是认为是默认的最新版本.gradle

classpath 'com.android.tools.build:gradle:3.0.0'
...
android {
    compileSdkVersion 26
    defaultConfig {
        minSdkVersion 26
        targetSdkVersion 26
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
....
        compile "com.android.support:support-v4:26.1.0"
        compile "com.android.support:support-v13:26.1.0"
        compile "com.android.support:cardview-v7:26.1.0"
        compile "com.android.support:appcompat-v7:26.1.0"

使用stacktrace,我得到了

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':Application:packageDebug'.
> java.io.IOException: Execution of compression failed.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':Application:packageDebug'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
    at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
    at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)
    at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87)
    at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:626)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:581)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: org.gradle.tooling.BuildException: java.io.IOException: Execution of compression failed.
    at com.android.build.gradle.internal.scope.OutputScope.lambda$parallelForEachOutput$10(OutputScope.java:241)
    at com.android.build.gradle.internal.scope.OutputScope.parallelForEachOutput(OutputScope.java:236)
    at com.android.build.gradle.internal.scope.OutputScope.parallelForEachOutput(OutputScope.java:197)
    at com.android.build.gradle.internal.scope.OutputScope.parallelForEachOutput(OutputScope.java:181)
    at com.android.build.gradle.tasks.PackageAndroidArtifact.doFullTaskAction(PackageAndroidArtifact.java:449)
    at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:109)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
    at org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:46)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:121)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
    ... 29 more
Caused by: java.lang.RuntimeException: java.io.IOException: Execution of compression failed.
Caused by: java.io.IOException: Execution of compression failed.
    at com.android.apkzlib.zip.CentralDirectoryHeader.getCompressionInfoWithWait(CentralDirectoryHeader.java:431)
    at com.android.apkzlib.zip.ZFile.processAllReadyEntriesWithWait(ZFile.java:1749)
    at com.android.apkzlib.zip.ZFile.hasPendingChangesWithWait(ZFile.java:2623)
    at com.android.apkzlib.zfile.ApkZFileCreator.hasPendingChangesWithWait(ApkZFileCreator.java:180)
    at com.android.builder.internal.packaging.IncrementalPackager.hasPendingChangesWithWait(IncrementalPackager.java:319)
    at com.android.build.gradle.tasks.PackageAndroidArtifact.doTask(PackageAndroidArtifact.java:672)
    at com.android.build.gradle.tasks.PackageAndroidArtifact.splitFullAction(PackageAndroidArtifact.java:500)
    at com.android.build.gradle.internal.scope.OutputScope.lambda$parallelForEachOutput$6(OutputScope.java:186)
    at com.android.build.gradle.internal.scope.OutputScope.lambda$parallelForEachOutput$7(OutputScope.java:203)
    at com.android.build.gradle.internal.scope.OutputScope.lambda$null$8(OutputScope.java:225)
    Suppressed: java.io.IOException: Failed to obtain compression information for entry
        at com.android.apkzlib.zip.ZFile.processAllReadyEntries(ZFile.java:1727)
        at com.android.apkzlib.zip.ZFile.processAllReadyEntriesWithWait(ZFile.java:1741)
        at com.android.apkzlib.zip.ZFile.update(ZFile.java:904)
        at com.android.apkzlib.zip.ZFile.close(ZFile.java:1196)
        at com.android.apkzlib.zfile.ApkZFileCreator.close(ApkZFileCreator.java:189)
        at com.google.common.io.Closer.close(Closer.java:216)
        at com.android.builder.internal.packaging.IncrementalPackager.close(IncrementalPackager.java:332)
        at com.android.build.gradle.tasks.PackageAndroidArtifact.doTask(PackageAndroidArtifact.java:678)
        at com.android.build.gradle.tasks.PackageAndroidArtifact.splitFullAction(PackageAndroidArtifact.java:500)
        at com.android.build.gradle.internal.scope.OutputScope.lambda$parallelForEachOutput$6(OutputScope.java:186)
        at com.android.build.gradle.internal.scope.OutputScope.lambda$parallelForEachOutput$7(OutputScope.java:203)
        at com.android.build.gradle.internal.scope.OutputScope.lambda$null$8(OutputScope.java:225)
        at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)
        at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
        at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
        at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
        at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
    Caused by: java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Self-suppression not permitted
        at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:503)
        at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:462)
        at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get(AbstractFuture.java:79)
        at com.android.apkzlib.zip.ZFile.processAllReadyEntries(ZFile.java:1722)
        ... 16 more
    Caused by: java.lang.IllegalArgumentException: Self-suppression not permitted
        at com.android.apkzlib.zip.compress.DeflateExecutionCompressor.immediateCompress(DeflateExecutionCompressor.java:72)
        at com.android.apkzlib.zip.compress.ExecutorCompressor.lambda$compress$0(ExecutorCompressor.java:54)
    Caused by: java.lang.OutOfMemoryError: Java heap space
Caused by: java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Self-suppression not permitted
    at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:503)
    at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:482)
    at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get(AbstractFuture.java:79)
    at com.android.apkzlib.zip.CentralDirectoryHeader.getCompressionInfoWithWait(CentralDirectoryHeader.java:425)
    ... 9 more
    [CIRCULAR REFERENCE:java.lang.IllegalArgumentException: Self-suppression not permitted]

* Get more help at https://help.gradle.org 
BUILD FAILED in 12s

2 个答案:

答案 0 :(得分:8)

我最近也遇到了这个问题。发生这种情况是因为我在资产中包含了一个非常大的zip文件。我通过在应用build.gradle

中添加dexoptions来修复此问题
android {
    dexOptions {
        javaMaxHeapSize "4g"
    } 
}

增加JVM堆大小

org.gradle.jvmargs=-Xmx4608M

喜欢这样。转到gradle.properties找到此选项。

答案 1 :(得分:0)

这在macOS上突然发生在我身上。在我的情况下,重新启动计算机后错误消失了。