0

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>
Kaushal28
  • 503
  • 1
  • 6
  • 18
  • 2
    This is not a duplicated. They are trying to use Maven, instead of adding a Jar Library. – Gatusko Jan 12 '17 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. – Kaushal28 Jan 12 '17 at 16:44

1 Answers1

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>
Gatusko
  • 2,503
  • 1
  • 17
  • 25
  • same problem after updating. I think all dependencies are old which I'm using. – Kaushal28 Jan 12 '17 at 16:18
  • can I use this type of dependencies block in pom.xml?? – Kaushal28 Jan 12 '17 at 16:19
  • Answer Edited. Check the dependecies they are in Version 1.22 and you are using 1.12-beta. I hope this works – Gatusko Jan 12 '17 at 16:19
  • And no, You can't use it in a pom.xml check in the maven repository the pom version of each one – Gatusko Jan 12 '17 at 16:20
  • but how can I find that required dependencies in that site which you mentioned? – Kaushal28 Jan 12 '17 at 16:24
  • because there is no repo for `com.google.api.client.util.store` – Kaushal28 Jan 12 '17 at 16:27
  • Answer Edited Hope it finally solve your problem. You need to found the **google.api.client** and your version you are using is too old that is not implemented yet. – Gatusko Jan 12 '17 at 16:37
  • now it solved the problem. But how did you come to know about using the repository and dependencies? any general approaches? Now It's giving nullPointerException at some line, but That is not the question, so thanks and accept. – Kaushal28 Jan 12 '17 at 16:52