Reputation: 3495
Caused by: java.lang.UnsupportedClassVersionError: com/google/common/annotations/VisibleForTesting : Unsupported major.minor version 52.0 (unable to load class com.google.common.annotations.VisibleForTesting)
Suddenly, without any change related to gradle or java jdk/jre version, i'm getting this run time error on my build server (ec2). I'm not getting it if I run it on my local computer.
I've made sure that java -version returns 1.7.0_x for both my build server and on my local computer. It was just fine for such a long time until today.
Upvotes: 3
Views: 1371
Reputation: 2585
Had the same issue when re-building an unmodified application after returning from vacations. A library from the dependency tree now dependends on the latest version of the Google Guava library, which requires java 1.8.
From the exception you can read that com/google/common/annotations/VisibleForTesting
causes your issue. The annotation type VisibleForTesting is part of the Google Guava library. Since a few weeks Guava Release 21.0 is available. From the Release Notes you can read...
Important: Guava 21.0 requires Java 8.
You might not have changed your application's dependency tree, but for all that an indirect dependency to Guava 21.0 does exist. In my case it was the com.googlecode.owasp-java-html-sanitizer which depends on Guava 21.0. Downloading the JAR and looking into the dependency configuration (in my case maven) I saw that a Guava version >= 11.0 is required. This will be resolved to the latest version, thus 21. The dependency hierarchie view in my IDE came to the same conclusion.
Since you have upgraded your build server to JRE 1.8 in the meantime, the issue is gone (on your build server). Be aware: when you push your application into production your server will require JRE 1.8, too.
Upvotes: 3