Search code examples
gradlebuildjardependenciesguava

Guava dependency in gradle


I have added the below dependency in build.gradle.

dependencies {
    implementation("com.google.guava:guava:24.0-jre")
}

But when I try to use Sets and zip in my code it's showing error. When I checked I could see that these imports are not downloaded.

import com.google.common.collect.Sets;
import static com.google.common.collect.Streams.zip;

Could someone help me with the correct dependency in build.gradle?


Solution

  • The dependency itself is correct and should provide you with these classes. Perhaps dependency wasn't resolved and downloaded from the repository.

    If you are using IntellJIdea, try to reload gradle dependencies (such option should appear when you are viewing e.g. build.gradle), so IDE will download and put them into your classpath automatically.