gpt4 book ai didi

android - 将 Google API Java 客户端库和日历 API Java 库添加到 Maven 依赖项

转载 作者:行者123 更新时间:2023-11-29 00:33:34 27 4
gpt4 key购买 nike

我有一个使用 Google Calendar v3 API 的 Android 项目。

我正在使用 Google API ClientCalendar API Java用于在 Google 日历上执行查询的库。

我在设置 maven 依赖项时遇到问题。我已经使用文档中的 ID 将这些库添加到我的 pom.xml 中,但其中一些已经过时,所以我最终得到了这个 pom.xml

我不得不把 <scope>provided</scope>到 google-api-client、google-http-client-jackson 和 google-http-client-android 库,因为 Maven 在尝试对这些库进行 dex 时失败。

Failed to execute goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.4.1:dex (default-dex)

现在这个 pom.xml 成功创建了 .apk 并将其安装在设备上。但是,当我尝试使用提供的库对日历 API 进行查询时,应用程序失败,提示找不到某些类。

12-19 17:32:17.247: E/dalvikvm(15119): Could not find class 'com.google.api.services.calendar.model.TimePeriod', referenced from method 

当我从 Eclipse 构建应用程序时(所有 .jars 都在/libs 文件夹中)一切正常。

所以我想知道是否有将这些依赖项添加到 Maven 脚本的正确方法。Google 有很多带有无效链接或示例的过时文档。否则我将不得不摆脱 Google 库并自己编写日历 API 查询。

我们将不胜感激任何帮助。

回答:

xpp3.jar 导致了这个问题,因为它有来自 javax 包的类。我不得不手动将它从所有 Google 库中排除:

            <exclusion>
<artifactId>xpp3</artifactId>
<groupId>xpp3</groupId>
</exclusion>

最佳答案

阿尔乔姆,

我看到下一个错误并建议如何修复它:

[INFO] trouble processing "javax/xml/namespace/QName.class":
[INFO]
[INFO] Ill-advised or mistaken usage of a core class (java.* or javax.*)
[INFO] when not building a core library.

这是 Java 核心文件。尝试找出哪些依赖项正在使用它 (mvn dependency:tree)。

关于android - 将 Google API Java 客户端库和日历 API Java 库添加到 Maven 依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13957241/

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