简体   繁体   English

两个依赖项使用相同的库但具有不同的版本

[英]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.

相关问题 同一个项目使用不同版本的分页库 - Use different versions of paging library in the same project 如何通过Gradle使Android Studio中的两个不同模块使用同一库的不同版本 - How to make two different modules in Android Studio use different versions of the same library via Gradle 对 2 个不同的库模块使用相同的依赖项 - Use same dependencies for 2 different library modules 如果同一android项目的两个android模块使用不同的支持库版本会怎样? - What happens if two android modules of the same android project use different support library versions? 同一个库的两个不同版本是否可以共存? - Is it possible to have two different versions of a same library coexist? 在我的应用程序中使用两个不同版本的okhttp库可以吗? - Is it OK to use two different versions of okhttp library in my app? 与相同的库但版本不同发生冲突 - Conflict with same library but with different versions 使用不同版本的 MotionLayout 和 ConstraintLayout 依赖项 - Use MotionLayout and ConstraintLayout dependencies with different versions 对2个不同的SDK版本使用相同的drawable - Use the same drawable for 2 different SDK versions 如何强制android studio为项目和库使用不同的库版本 - How to force android studio to use different library versions for project and library
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM