RobN's answer is correct, but I thought I would write a slightly longer answer with my own experience. This is due to this issue and discussions of the problems of Guava 776 and 1095 mentioned by RobN.
I had the same problem trying to access
com.google.common.io.BaseEncoding.base64()
Eclipse claims that the base64 element does not exist and Gradle build throws an error in the question:
[ant:scalac] error: error while loading BaseEncoding, class file '.../guava-16.0.jar(com/google/common/io/BaseEncoding.class)' is broken
The error is caused by an optional dependency on some annotations in Guava pom.xml . As explained in this answer , the Java compiler ignores annotations for which the corresponding class file was not found, but the Scala compiler requires compromise.
Explicitly adding a dependency, which is optional, should solve the problem.
In this particular case, Guava pom.xml has the following additional dependency and adding dependency declarations below to your project will solve the problem:
Gradle:
compile 'com.google.code.findbugs:jsr305:2.0.2'
Maven:
<dependency> <groupId>com.google.code.findbugs</groupId> <artifactId>jsr305</artifactId> <version>2.0.2</version> </dependency>
Peter Lamberg
source share