When I build my Guava dependent project with Gradle using:
//build.gradle
plugins {
id 'java'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile group: 'com.google.guava', name: 'guava', version: '22.0'
}
task wrapper(type: Wrapper) {
gradleVersion = '3.3' //Tried 3.1 - 4.0.1
distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip"
}
I get the following runtime error when running the project in Intellij:
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/collect/Multiset
The libraries are definitely in the classpath and I cannot figure out why this is happening.
I have solved this problem by switching to an older Gradle version (3.1, 3.2, 3.3 all work).
Therefore, I believe the problem lies with Gradle 3.4+ (3.4, 3.5.1, 4.0 and 4.0.1) all of which I have tried and received the NoClassDefFoundError.
There is no mention of a Gradle version required in the Guava documentation
Is Guava incompatible with newer versions of Gradle?