2016-10-19 86 views
4

我在android studio中爲Android應用程序創建了一個項目。 該項目有6個模塊(3個內部庫,一個Android應用程序模塊,一個可穿戴模塊和一個用於在應用程序和可穿戴設備之間共享代碼的模塊),一切都運行良好,直到我們決定更改應用程序的最小android sdk。Android Gradle產生TransformException異常:java.util.zip.ZipException:在transformClassesWithDexForRelease期間打開zip文件時出錯

它最初與16+兼容,我們想讓它成爲21+。 我們試着只更改最低sdk,升級最低sdk和編譯sdk(到23和24或21 ...),甚至升級構建工具(到23 24),但似乎沒有任何工作... 我當我啓用gradle守護進程時,我設法讓它「有時」起作用,這是因爲我真的不明白,但這對於構建CI來說並不是一個好的選擇。

因此,在徹底的絕望,我問如果任何人有可能是什麼問題的線索......

的錯誤是com.android.build.api.transform.TransformException:java.util.zip .ZipException:打開zip文件時出錯。 我從來沒有看到它建立時,但我們也運行「connectedAndroidTest」我們似乎打包每個模塊,這個錯誤發生在隨機模塊和建設 - 信息或 - 調試並沒有指出哪個zip文件打開導致錯誤。 ..

1:Task failed with an exception. 
----------- 
* What went wrong: 
Execution failed for task ':shared:transformClassesWithDexForDebugAndroidTest'. 
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: error in opening zip file 

* Try: 
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. 
============================================================================== 

2: Task failed with an exception. 
----------- 
* What went wrong: 
Execution failed for task ':common:messages:transformClassesWithDexForDebugAndroidTest'. 
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: error in opening zip file 

* Try: 
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. 
============================================================================== 

3: Task failed with an exception. 
----------- 
* What went wrong: 
Execution failed for task ':common:upnp:transformClassesWithDexForDebugAndroidTest'. 
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: error in opening zip file 

* Try: 
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. 
============================================================================== 

4: Task failed with an exception. 
----------- 
* What went wrong: 
Execution failed for task ':common:utils:transformClassesWithDexForDebugAndroidTest'. 
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: error in opening zip file 

* Try: 
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. 
============================================================================== 

完整的堆棧:

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':common:utils:transformClassesWithDexForDebugAndroidTest'. 
     at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69) 
     at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46) 
     at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35) 
     at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:66) 
     at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58) 
     at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.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:53) 
     at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43) 
     at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203) 
     at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185) 
     at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:66) 
     at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50) 
     at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:25) 
     at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:110) 
     at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37) 
     at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37) 
     at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExecuter.java:23) 
     at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:43) 
     at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32) 
     at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37) 
     at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30) 
     at org.gradle.initialization.DefaultGradleLauncher$4.run(DefaultGradleLauncher.java:153) 
     at org.gradle.internal.Factories$1.create(Factories.java:22) 
     at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91) 
     at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:53) 
     at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:150) 
     at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:32) 
     at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:98) 
     at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:92) 
     at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91) 
     at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:63) 
     at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:92) 
     at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:83) 
     at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:99) 
     at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28) 
     at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35) 
     at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:48) 
     at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:30) 
     at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:81) 
     at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:46) 
     at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:52) 
     at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36) 
     at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) 
     at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37) 
     at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) 
     at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26) 
     at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) 
     at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34) 
     at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) 
     at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74) 
     at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72) 
     at org.gradle.util.Swapper.swap(Swapper.java:38) 
     at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72) 
     at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) 
     at org.gradle.launcher.daemon.server.health.DaemonHealthTracker.execute(DaemonHealthTracker.java:40) 
     at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) 
     at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60) 
     at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36) 
     at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) 
     at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:72) 
     at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36) 
     at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) 
     at org.gradle.launcher.daemon.server.health.HintGCAfterBuild.execute(HintGCAfterBuild.java:41) 
     at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) 
     at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50) 
     at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:237) 
     at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54) 
     at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40) 
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
     at java.lang.Thread.run(Thread.java:745) 
Caused by: java.lang.RuntimeException: com.android.build.api.transform.TransformException: java.util.zip.ZipException: error in opening zip file 
     at com.android.builder.profile.Recorder$Block.handleException(Recorder.java:54) 
     at com.android.builder.profile.ThreadRecorder$1.record(ThreadRecorder.java:57) 
     at com.android.builder.profile.ThreadRecorder$1.record(ThreadRecorder.java:47) 
     at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:173) 
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
     at java.lang.reflect.Method.invoke(Method.java:498) 
     at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75) 
     at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.doExecute(AnnotationProcessingTaskFactory.java:245) 
     at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:221) 
     at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.execute(AnnotationProcessingTaskFactory.java:232) 
     at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:210) 
     at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80) 
     at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61) 
     ... 71 more 
Caused by: com.android.build.api.transform.TransformException: java.util.zip.ZipException: error in opening zip file 
     at com.android.build.gradle.internal.transforms.DexTransform.transform(DexTransform.java:423) 
     at com.android.build.gradle.internal.pipeline.TransformTask$3.call(TransformTask.java:178) 
     at com.android.build.gradle.internal.pipeline.TransformTask$3.call(TransformTask.java:174) 
     at com.android.builder.profile.ThreadRecorder$1.record(ThreadRecorder.java:55) 
     ... 84 more 
Caused by: 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:219) 
     at java.util.zip.ZipFile.<init>(ZipFile.java:149) 
     at java.util.zip.ZipFile.<init>(ZipFile.java:163) 
     at com.android.builder.core.AndroidBuilder.checkLibraryClassesJar(AndroidBuilder.java:1799) 
     at com.android.builder.core.AndroidBuilder.convertByteCode(AndroidBuilder.java:1464) 
     at com.android.build.gradle.internal.transforms.DexTransform.transform(DexTransform.java:406) 
     ... 87 more 
+0

你嘗試過嗎? http://stackoverflow.com/questions/23828085/android-studio-failed-to-complete-gradle-execution-error-in-opening-zip-file –

+0

是的,我做了...無論如何它發生在多個環境(開發以及我們的持續集成服務器) – MoAdiB

回答

1

如果錯誤是不上拉鍊的gradle但一個罐子本身,請確保您的compileSdkVersion,buildToolsVersion和targetSdkVersion是一致的。

如果仍然存在錯誤,請嘗試使用不同版本的Android gradle插件構建,我遇到了與com.android.tools.build:gradle:2.1.3類似的問題,並在升級到2.2後消失.0

相關問題