google-ads-java: Unable to authenticate GoogleAdsClient over Java 1.8

I’m trying to use Google Ads API, I already have my ads.properties file ready, and I added the following dependencies to my pom file:

<dependency> <groupId>com.google.api-ads</groupId> <artifactId>google-ads</artifactId> <version>9.0.0</version> </dependency> <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>27.0-jre</version> </dependency> <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpcore</artifactId> <version>4.4.8</version> </dependency>

But when I try to run the code like this: File file = new File(this.getClass().getClassLoader().getResource("/ads.properties").getFile()); GoogleAdsClient googleAdsClient = GoogleAdsClient.newBuilder().fromPropertiesFile(file).build();

I get the following error: org.glassfish.jersey.server.ContainerException: java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;)V

Is there a problem with the library? And how could I fix it? Would this be a problem with my credentials?

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 22 (12 by maintainers)

Most upvoted comments

As discssed on VC, this is now fixed. The culprit was

       <dependency>
           <groupId>com.google.apis</groupId>
           <artifactId>google-api-services-oauth2</artifactId>
           <version>v2-rev83-1.19.0</version>
       </dependency>

and updating to latest resolved this.

Can you create a repo with a minimal failing example please?