两个依赖项使用相同的库,但版本不同 [英] Two dependencies use the same library but with different versions

查看:338
本文介绍了两个依赖项使用相同的库,但版本不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎我有Picasso库2.4.0,但是twitter也使用库的2.3.2版本.我的问题是... 2.3.2库是否与较新版本一起下载?还是只有2.4.0被下载并且也被twitter使用?我应该排除2.3.2一个,然后twitter会自动使用2.4.0吗?这样安全吗?较新的版本可能与twitter库不兼容,不是吗?

It seems that I have the Picasso library, 2.4.0 but twitter also uses the 2.3.2 version of the library. My question is ... does the 2.3.2 library get downloaded alongside the newer version? Or just the 2.4.0 is downloaded and is used by twitter as well ? Should I exclude the 2.3.2 one and twitter will use the 2.4.0 automatically? Is this safe? The newer version might not be compatible with the twitter library, no?

在这种情况下,我感到困惑.我应该排除哪个库(如果可以排除的话).

I'm confused how I should proceed in this case. Which library should I exclude (if I can exclude one that is).

gradle -q app:dependencyInsight --dependency picasso --configuration compile

com.squareup.picasso:picasso:2.4.0 (conflict resolution)
\--- compile

com.squareup.picasso:picasso:2.3.2 -> 2.4.0
\--- com.twitter.sdk.android:tweet-ui:1.1.0
     +--- compile
     \--- com.twitter.sdk.android:twitter:1.1.1
          \--- compile

(*) - dependencies omitted (listed previously)

推荐答案

根据

Gradle提供以下冲突解决策略:

Gradle offers the following conflict resolution strategies:

最新:使用最新版本的依赖项.这是Gradle的默认策略,只要版本向后兼容,通常是一个合适的选择.

Newest: The newest version of the dependency is used. This is Gradle's default strategy, and is often an appropriate choice as long as versions are backwards-compatible.

失败:版本冲突导致构建失败.此策略要求在构建脚本中显式解决所有版本冲突.有关如何明确选择特定版本的详细信息,请参见ResolutionStrategy.

Fail: A version conflict results in a build failure. This strategy requires all version conflicts to be resolved explicitly in the build script. See ResolutionStrategy for details on how to explicitly choose a particular version.

因此Gradle将使用Picasso 2.4.0管理依赖项.

So Gradle is going to use Picasso 2.4.0 managing dependencies.

这会是个问题吗?可能吧.如果Twitter使用的方法和/或签名已从2.3.x更改为2.4,则会遇到问题.如果它们彼此向后兼容,您将不会有任何问题.

Will this be a problem? Possibly. You will get issues if Twitter uses method and/or signatures that have changed from going to 2.3.x to 2.4. You will get no issues if they are backwards compatible with each other.

我现在确实看到了 Twitter SDK 实际上已将其Picasso库升级到2.5.2(最新版本).如果您的项目导入了毕加索,那么您也可以对其进行更新(也许应该).如果它是另一个模块中的依赖项,那么您也可以更新该模块.

I do now see that Twitter SDK has actually upgraded their Picasso library to 2.5.2 (The latest). If your project imports Picasso, then you can update it as well (and probably should). If it's a dependency in another module, then you may be able to update that module as well.

另一个选择是将毕加索降级到2.3.2或使用解决方案以使用较低版本.除非您必须,否则我不建议这样做.

The other option is to downgrade Picasso to 2.3.2 or use a ResolutionStrategy to use the lower version. I wouldn't recommend this unless you have to.

这篇关于两个依赖项使用相同的库,但版本不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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