这种依赖性给了我一个jar的两个版本。我该如何解决? [英] This dependency gives me two versions of one jar. How do I fix this?

查看:289
本文介绍了这种依赖性给了我一个jar的两个版本。我该如何解决?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Gradle作为我的项目。我在build.gradle中指定的一个依赖关系是

compile'org.glassfish.jersey.media:jersey-media-moxy:2.0'



这适用于普通的Java应用程序,但是当我尝试在Android上构建它时,我得到了:

在查看引用哪些库时,很明显,有两个 javax.inject-2.3.0-b05.jar javax.inject- 1.jar ,我发现它是由上面的依赖关系添加的。我猜这个'重复'jar是造成构建错误的原因。



我该如何解决这个问题?为什么依赖包含两个相同的jar?有没有办法使这两个罐子的Android版本生成或删除这些罐子之一?

你有一个依赖树akin

 项目
| --- org.glassfish.jersey.media:jersey- media-moxy:2.0
| \ --- *:javax.inject:1
\ --- *:javax.inject:2.3.0-b05

其中*是组,我怀疑它们可能与这两组不同。

尝试了解您的依赖关系正在通过使用依赖项任务

  gradle dependency 

如果您需要排除依赖项,请在标记中输入它,类似于以下示例

 编译('org.hibernate:hibernate:3.1'){
//排除特定的传递依赖:
排除模块:'cglib'//按工件名称
排除组:'org。 jmock'// by group
exclude group:'org.unwanted',module:'iAmBuggy'// by name and group
}


I'm using Gradle for my project. One of the dependencies I have specified in my build.gradle is
compile 'org.glassfish.jersey.media:jersey-media-moxy:2.0'

This works fine on a normal Java application, however when I try to build it on Android I get:

When looking at which libraries are referenced, it's clear that there's both javax.inject-2.3.0-b05.jar and javax.inject-1.jar, which I found are added by the dependency above. I'm guessing that this 'duplicate' jar is what causes the build error.

How do I go around this? Why does the dependency include two of the same jar? Is there a way to either make the Android version build with these two jars or to remove one of these jars?

解决方案

It appears that you have a dependency tree akin

project
|--- org.glassfish.jersey.media:jersey-media-moxy:2.0
| \--- *:javax.inject:1
\--- *:javax.inject:2.3.0-b05

Where * is the group, which I suspect may be different from those two.

Try getting an idea of how your dependencies are being grabbed by using the dependency task

gradle dependency

Should you need to exclude a dependency enter it in the tag, similar to the below example

compile('org.hibernate:hibernate:3.1') {
  //excluding a particular transitive dependency:
  exclude module: 'cglib' //by artifact name
  exclude group: 'org.jmock' //by group
  exclude group: 'org.unwanted', module: 'iAmBuggy' //by both name and group
}

这篇关于这种依赖性给了我一个jar的两个版本。我该如何解决?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆