Solve issue “java.lang.NoSuchMethodError” com.google.common.collect.ImmutableList

When I was trying to add these below dependencies for Gmail API access:

<dependency>
    <groupId>com.google.api-client</groupId>
    <artifactId>google-api-client</artifactId>
    <version>1.28.0</version>
</dependency>
<dependency>
    <groupId>com.google.oauth-client</groupId>
    <artifactId>google-oauth-client-jetty</artifactId>
    <version>1.28.0</version>
</dependency>
<dependency>
    <groupId>com.google.apis</groupId>
    <artifactId>google-api-services-gmail</artifactId>
    <version>v1-rev103-1.25.0</version>
</dependency>

Suddenly my maven tests start failing with the error below:

Capture

I figured out that I need to add this google guava dependency. After added it, the tests work like a magic.

Update your pom.xml to include:

<dependency>
    <groupId>com.google.guava</groupId>
    <artifactId>guava</artifactId>
    <version>27.0.1-jre</version>
</dependency>

Leave a comment