I'm working with java and google api calendar, but when I try to create the object calendar with this code :
Calendar calendar = new Calendar.Builder(HTTP_TRANSPORT,JSON_FACTORY, credential).build();
The console show me the next exception:
Exception in thread "main" java.lang.NoSuchMethodError: com.google.api.client.googleapis.services.json.AbstractGoogleJsonClient.<init>(Lcom/google/api/client/http/HttpTransport;Lcom/google/api/client/http/HttpRequestInitializer;Ljava/lang/String;Ljava/lang/String;Lcom/google/api/client/json/JsonObjectParser;Lcom/google/api/client/googleapis/services/GoogleClientRequestInitializer;Ljava/lang/String;Z)V
at com.google.api.services.calendar.Calendar.<init>(Calendar.java:135)
at com.google.api.services.calendar.Calendar$Builder.build(Calendar.java:4603)
at cl.packg.Quickstart.main(Quickstart.java:162)
Additional information:
For HTTP_TRANSPORT variable, I'm using this: com.google.api.client.http.HttpTransport
.
For JSON_FACTORY variable, i'm using this: com.google.api.client.json.JsonFactory
.
And for credential variable, i'm using this : com.google.api.client.auth.oauth2.Credential
.
Thanks
In the Calendar insert method , the sample to create calendar was provided:
Calendar service = new Calendar.Builder(httpTransport, jsonFactory, credentials)
.setApplicationName("applicationName").build();
// Create a new calendar
com.google.api.services.calendar.model.Calendar calendar = new Calendar();
calendar.setSummary("calendarSummary");
calendar.setTimeZone("America/Los_Angeles");
// Insert the new calendar
Calendar createdCalendar = service.calendars().insert(calendar).execute();
System.out.println(createdCalendar.getId());
Your code seems to be missing the .setApplicationName("applicationName")
part.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.