Gradle传递依存关系排除功能无法正常工作。(如何摆脱com.google.guava:guava-jdk5:13.0?)

【字号: 日期:2024-02-28浏览:37作者:雯心
如何解决Gradle传递依存关系排除功能无法正常工作。(如何摆脱com.google.guava:guava-jdk5:13.0?)?

事实证明,guava-jdk5仍在维护中。

所以我改变了这个:

compile (’com.google.guava:guava:15.0’){force = true}

为了这:

compile(’com.google.guava:guava-jdk5:17.0’) { force = true }

这样就解决了我的问题,现在我可以将Google App Engine项目中“ com.google.common”包中的类与所有描述的依赖项一起使用

解决方法

这是我的build.gradle的片段:

compile ’com.google.api-client:google-api-client:1.19.0’compile ’com.google.apis:google-api-services-oauth2:v2-rev77-1.19.0’compile ’com.google.apis:google-api-services-plus:v1-rev155-1.19.0’compile ’com.google.appengine.tools:appengine-gcs-client:0.4.1’compile ’com.google.appengine.tools:appengine-mapreduce:0.8’

您可以通过dependencyInsight看到导入的番石榴的多个版本:

com.google.guava:guava:15.0 (conflict resolution)com.google.guava:guava:14.0.1 -> 15.0+--- com.googlecode.objectify:objectify:4.1.3| --- default--- net.eusashead.spring:spring-cache-gae:1.0.0.RELEASE --- defaultcom.google.guava:guava:[15.0,15.99] -> 15.0+--- com.google.appengine.tools:appengine-gcs-client:0.4.1| +--- default| +--- com.google.appengine.tools:appengine-mapreduce:0.8| | --- default| --- com.google.appengine.tools:appengine-pipeline:0.2.10| --- com.google.appengine.tools:appengine-mapreduce:0.8 (*)+--- com.google.appengine.tools:appengine-mapreduce:0.8 (*)--- com.google.appengine.tools:appengine-pipeline:0.2.10 (*)com.google.guava:guava-jdk5:13.0--- com.google.api-client:google-api-client:1.19.0 +--- default +--- com.google.apis:google-api-services-oauth2:v2-rev77-1.19.0 | --- default +--- com.google.apis:google-api-services-plus:v1-rev155-1.19.0 | --- default +--- com.google.appengine.tools:appengine-gcs-client:0.4.1 | +--- default | +--- com.google.appengine.tools:appengine-mapreduce:0.8 | | --- default | --- com.google.appengine.tools:appengine-pipeline:0.2.10 | --- com.google.appengine.tools:appengine-mapreduce:0.8 (*) +--- com.google.api-client:google-api-client-appengine:1.17.0-rc | --- com.google.appengine.tools:appengine-gcs-client:0.4.1 (*) +--- com.google.apis:google-api-services-storage:v1-rev1-1.18.0-rc | --- com.google.appengine.tools:appengine-gcs-client:0.4.1 (*) +--- com.google.apis:google-api-services-bigquery:v2-rev154-1.19.0 | --- com.google.appengine.tools:appengine-mapreduce:0.8 (*) --- com.google.api-client:google-api-client-servlet:1.17.0-rc --- com.google.api-client:google-api-client-appengine:1.17.0-rc (*)(*) - dependencies omitted (listed previously)

我尝试通过执行以下操作删除对:的依赖:

compile (’com.google.api-client:google-api-client:1.19.0’){exclude group: ’com.google.guava’,module: ’guava-jdk5’ }compile (’com.google.api-client:google-api-client:1.19.0’){exclude group: ’com.google.guava’,}

但是dependencyInsight保持不变。我也试过

compile (’com.google.guava:guava:15.0’){force = true}

但是依赖依赖的见解仍然保持不变。如何摆脱com.google.guava:guava-jdk5:13.0?

详细信息:我已经在Windows 8.1盒上尝试过gradle 1.2和2.1

我尝试此操作的原因是摆脱了此异常:

java.lang.NoSuchMethodError: com.google.common.base.Stopwatch.createStarted()Lcom/google/common/base/Stopwatch;

相关文章: