在依赖项中Gradle重复类 [英] Gradle duplicate classes in dependencies

查看:292
本文介绍了在依赖项中Gradle重复类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个android应用程序,并在使用recaptcha和easywsdl存储库.这两个存储库都包含okhttp和okio jar,在启动存在重复类的应用程序时出现错误.但是,这些并不相同.如果我从项目(由recaptcha存储库添加)中排除了okhttp,则recaptcha并没有由recaptcha添加的okhttp.jar中描述的特定方法.

I am building an android application and am using recaptcha and easywsdl repositories. These both repositories contain okhttp and okio jars and I get error while starting app that duplicate classes exist. However, these are not the same. If I exclude okhttp from the project (added by recaptcha repository) recaptcha doesn't have particular methods that are described in okhttp.jar added by recaptcha.

代码段: http://pastebin.com/fDuYUH76

不知道如何将其粘贴到此处.格式化崩溃.

Don't know how to paste it here. Formatting crashes.

推荐答案

Gradle不能解决由两个具有共享类的不同jar引起的冲突.如果您有两个jar文件具有相同的artifactId和不同的版本,那么它将仅使用其中一个.如果您有两个不同的artifactId,则gradle对此无能为力.

Gradle does not solve conflicts that arise from two different jars having shared classes. If you have two jars with same artifactId and different version, it will only take one of them. If you have two different artifactId's, gradle cannot do anything about it.

如果同时使用两个jar会使您的应用程序崩溃,则只能使用其中一个.如果您的应用程序无法仅使用其中一个jar来运行,则可能无法按照您的预期方式进行构建.

If the simultaneous use of the two jars makes your application crash, you can only use one of them. If your application doesn't run with only one of the jars, it probably cannot be built in the way you intend it.

顺便说一句:这不是拥有多个存储库的问题,而是在类路径上具有冲突的jar的问题.

By the way: This is not a problem of having multiple repositories, but a problem of having clashing jars on the classpath.

这篇关于在依赖项中Gradle重复类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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