[英]Two dependencies use the same library but with different versions
It seems that I have the Picasso library, 2.4.0 but twitter also uses the 2.3.2 version of the library. 看来我有Picasso库,2.4.0但是twitter也使用了2.3.2版本的库。 My question is ... does the 2.3.2 library get downloaded alongside the newer version?
我的问题是...... 2.3.2库是否与新版本一起下载? Or just the 2.4.0 is downloaded and is used by twitter as well ?
或者只是下载2.4.0并且也被twitter使用? Should I exclude the 2.3.2 one and twitter will use the 2.4.0 automatically?
我应该排除2.3.2,Twitter会自动使用2.4.0吗? Is this safe?
这样安全吗? The newer version might not be compatible with the twitter library, no?
较新的版本可能与twitter库不兼容,不是吗?
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)
According to the Gradle docs : 根据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.
这是Gradle的默认策略,只要版本向后兼容,它通常是一个合适的选择。
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.
有关如何明确选择特定版本的详细信息,请参阅ResolutionStrategy。
So Gradle is going to use Picasso 2.4.0 managing dependencies. 所以Gradle将使用Picasso 2.4.0管理依赖项。
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.
如果Twitter使用的方法和/或签名已从2.3.x更改为2.4,则会出现问题。 You will get no issues if they are backwards compatible with each other.
如果它们彼此向后兼容,您将不会遇到任何问题。
I do now see that Twitter SDK has actually upgraded their Picasso library to 2.5.2 (The latest). 我现在看到Twitter SDK实际上已经将他们的Picasso库升级到2.5.2(最新版)。 If your project imports Picasso, then you can update it as well (and probably should).
如果您的项目导入Picasso,那么您也可以更新它(也可能应该)。 If it's a dependency in another module, then you may be able to update that module as well.
如果它是另一个模块的依赖项,那么您也可以更新该模块。
The other option is to downgrade Picasso to 2.3.2 or use a ResolutionStrategy to use the lower version. 另一种选择是将Picasso降级到2.3.2或使用ResolutionStrategy来使用较低版本。 I wouldn't recommend this unless you have to.
除非你必须,否则我不会推荐这个。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.