Search code examples
javamavengoogle-sheetsgoogle-cloud-platform

Maven Google Sheets version issue


I have a Java Maven project that needs google-api-client version 2.0.0+ (currently using 2.4.0):

<dependency>
    <groupId>com.google.api-client</groupId>
    <artifactId>google-api-client</artifactId>
    <version>2.4.0</version>
</dependency>

I also need the Google Sheets Java API. Using latest (but tried many different versions with same error):

<dependency>
    <groupId>com.google.apis</groupId>
    <artifactId>google-api-services-sheets</artifactId>
    <version>v4-rev614-1.18.0-rc</version>
</dependency>

When I try to start the project with these two dependencies together, I get the following error:

Caused by: java.lang.IllegalStateException: You are currently running with version 2.4.0 of google-api-client. You need at least version 1.15 of google-api-client to run version 1.18.0-rc of the Google Sheets API library.

How can I go around this without trying to downgrade Google API Client?


Solution

  • As per the comment, my problem was that I was looking into mvnrepository as the source of truth for the latest artifact version. This version was, in fact, 4 years old despite being the latest listed on mvnrepository.

    One can find newer versions in the Sonatype repository which will not show this error.