How can I resolve "cannot read zip file"?

I have a project that compiles using gradle with dependencies in a maven repo.

It has been working for many months, but when setting up a new machine, I am unable to compile, with error accessing a dependency file.

[ant:javac] error: error reading /Users/rayj/.gradle/caches/artifacts-4/com.google.guava/guava/c12498cf18507aa6433a94eb7d3e77d5/jars/guava-11.0.2.jar; cannot read zip file

I was able to reproduce on another machine by removing my gradle cache ("~/.gradle/caches/artifacts-4/").

I was able to determine that the “corrupted” jar file(s) had a behavior different than “non-corrupted” jar files. For “non-corrupted” jar files, I can rename to “.zip” and extract the zip to see the contents of the file (as expected). For “corrupted” jar files, if I rename to “.zip” and extract the zip, the output is another jar file (unexpected). If I rename/extract again, then it properly extracts as the contents of the file (expected).

I can manually workaround this issue by: for each corrupt jar file - rename to .zip and extract to create a new jar (this turns a corrupt jar into a non-corrupt jar)

This suggests that the problem is solely related to a jar file being “corrupt”.

Although this works, it is a painful resolution to an automated build =)

I am looking for some guidance as to what may have caused this and how to troubleshoot the root issue.

The corrupted jar must be coming from somewhere: have you checked the repository that ‘guava-11.0.2.jar’ is downloaded from? Best bet could be to fix this problem at the source.

I was able to confirm that the guava jar as downloaded from its source was indeed valid (non-corrupted).

Good new ending to story, I realized that I was on an older version of gradle (1.6 milestone) - and this problem was resolved by upgrading to the release version (1.0).