gpt4 book ai didi

java - 尝试获取 Google 日历服务时出错

转载 作者:行者123 更新时间:2023-12-01 22:43:15 25 4
gpt4 key购买 nike

我正在开发一个 AppEngine 应用程序,我必须在其中使用 Google Calendar API。由于某些原因,我们没有使用此 API 的最新版本 (v3),我们正在使用 gdata-calendar-v2,该版本在明年 11 月之前仍然有效。

好吧,我有两种使用日历服务的方法。一方面,我在日历上添加一个新事件,并且执行以下操作:

CalendarService myService =  new CalendarService("my_calendar"); // error on this line   
myService.setUserCredentials(EMAIL, PASSWORD);

据我所知,它工作正常,并且我在日历上添加新 Activity 没有任何问题。

另一方面,我有另一种方法,我可以做一些不同的事情,但我使用相同的代码片段来连接到 Google 日历。在这种情况下,我收到此错误:

Caused by: java.lang.NoSuchMethodError: com.google.common.collect.ImmutableSet.copyOf([Ljava/lang/Object;)Lcom/google/common/collect/ImmutableSet;
at com.google.gdata.wireformats.AltFormat$Builder.setAcceptableTypes(AltFormat.java:399)
at com.google.gdata.wireformats.AltFormat$Builder.setAcceptableXmlTypes(AltFormat.java:387)
at com.google.gdata.wireformats.AltFormat.<clinit>(AltFormat.java:49)
at com.google.gdata.client.Service.<clinit>(Service.java:558)

我与 -collections- 一起使用的库,您可能感兴趣的是:

  • Guava 11(我已经更新到 18,也是同样的问题)。

我知道有一个非常相似的线程也有同样的问题 right here但有一个区别:它在我的项目的一种方法中工作正常,而在另一种方法中则不能正常工作。

你能帮我一下吗?

预先感谢您,迭戈。

解决方案:

我一直在谷歌搜索,我发现了这个thread我已将 Guava 更改为 guava-10.0.1.jar我不再收到此错误。

The latest version of the gdata client library for java (version 1.46.0 as of this writing, found here: https://code.google.com/p/gdata-java-client/downloads/list) still embeds google-collections-1.0-rc1.jar inside their dependencies, and at this point it's not able to be replaced by the latest guava version.

最佳答案

您很可能正在使用两个不同版本的 Guava。添加行

System.out.println(ImmutableSet.class.getClass().getResource("/"));

到异常之前的行以找出冲突版本所在的位置。

<小时/>

当前 Guava 有 method

public static <E> ImmutableSet<E> copyOf(E[] elements) {}

一些旧版本(例如 Google 集合)do not 。看起来像

com.google.gdata.wireformats.AltFormat$Builder

访问旧版本。

关于java - 尝试获取 Google 日历服务时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25783381/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com