1

I'm following this tutorial to sync my java app with Google calendar. But the following line is giving error:

import com.google.api.client.util.store.FileDataStoreFactory;

So I searched how to add this dependence to my project. But I can only found this documentation page. But I Don't understand how to add this.

Other dependencies I've added in pom.xml file.

And I'm not using that Gradle for my project which is described in the tutorial which I mentioned.

My pom.xml file looks like:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0  http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>mavenproject2</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
</properties>


<dependencies>
<dependency>
  <groupId>com.google.apis</groupId>
  <artifactId>google-api-services-calendar</artifactId>
  <version>v3-rev226-1.22.0</version>
</dependency>
<dependency>
   <groupId>com.google.api-client</groupId>
   <artifactId>google-api-client-java6</artifactId>
   <version>1.12.0-beta</version>
</dependency>
<dependency>
   <groupId>com.google.oauth-client</groupId>
   <artifactId>google-oauth-client-jetty</artifactId>
   <version>1.12.0-beta</version>
</dependency>
<dependency>
   <groupId>com.google.http-client</groupId>
   <artifactId>google-http-client-jackson2</artifactId>
   <version>1.12.0-beta</version>
</dependency>

</dependencies>

<repositories>
  <repository>
      <id>google-api-services</id>
      <url>https://oss.sonatype.org/content/repositories/releases/</url>
  </repository>
<repository>
    <id>google-api-services-beta</id>
    <url>http://google-api-client-libraries.appspot.com/mavenrepo</url>
</repository>
</repositories>
</project>
2
  • 2
    This is not a duplicated. They are trying to use Maven, instead of adding a Jar Library. Commented Jan 12, 2017 at 16:38
  • @JarrodRoberson I do not want to add jar files. Without reading whole question you downvoted and marked as duplicate. Even in adding maven, I've specific problem. Commented Jan 12, 2017 at 16:44

1 Answer 1

0

You are Using an old version of the google-api-client. The documentation that you found is pointing the version 1.20 and your dependecies are 1.12.0-Beta. Try to use and check what dependecies you need and don't use outdated dependecies or in beta-version. Check always the maven repository

dependencies {
    compile 'com.google.api-client:google-api-client:1.22.0'
    compile 'com.google.oauth-client:google-oauth-client-jetty:1.22.0'
    compile 'com.google.apis:google-api-services-calendar:v3-rev226-1.22.0'

}

Search this dependecies in the maven repository I think your dependecies are really different and outdated for the tutorial that are you trying to follow.

Gradle to Maven.

    <dependency>
      <groupId>com.google.api-client</groupId>
      <artifactId>google-api-client</artifactId>
      <version>1.22.0</version>
    </dependency>
    <dependency>
        <groupId>com.google.oauth-client</groupId>
        <artifactId>google-oauth-client-jetty</artifactId>
        <version>1.22.0</version>
    </dependency>
<dependency>
    <groupId>com.google.apis</groupId>
    <artifactId>google-api-services-calendar</artifactId>
    <version>v3-rev225-1.22.0</version>
</dependency>

And use this Repository instead

  <repository>
    <id>central</id>
    <url>http://repo1.maven.org/maven2/</url>
  </repository>
Sign up to request clarification or add additional context in comments.

8 Comments

same problem after updating. I think all dependencies are old which I'm using.
can I use this type of dependencies block in pom.xml??
Answer Edited. Check the dependecies they are in Version 1.22 and you are using 1.12-beta. I hope this works
And no, You can't use it in a pom.xml check in the maven repository the pom version of each one
but how can I find that required dependencies in that site which you mentioned?
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.