简体   繁体   English

使用 Gradle 实现多个库版本

[英]Implement multiple library versions with Gradle

I have two libraries, which both include by themself a different version of com.android.billingclient:billing ;我有两个库,它们本身都包含不同版本的com.android.billingclient:billing 1.2.2 and 2.0.3 1.2.22.0.3

I need to use both libraries in my project, and if I force the use of one, one of both libraries won't compile anymore.我需要在我的项目中使用这两个库,如果我强制使用一个,两个库中的一个将不再编译。

How can I use both versions of com.android.billingclient:billing in my project, so that they don't conflict with each other?如何在我的项目中同时使用com.android.billingclient:billing的两个版本,以免它们相互冲突?

The key phrase to finding the solution to your problem is: transitive dependency .找到解决问题的关键短语是: transitive dependency If you have 2 dependencies in your project that each have a sub-dependency (transitive dependency) on the same library but each uses different versions of that library then you'll need to tell one of them not to import that dependency.如果您的项目中有 2 个依赖项,每个依赖项在同一个库上都有一个子依赖项(传递依赖项),但每个依赖项都使用该库的不同版本,那么您需要告诉其中一个不要导入该依赖项。

Check out the discussion of this question in the Gradle Forums, I think it addresses your problem.查看 Gradle 论坛中对这个问题的讨论,我认为它解决了您的问题。 It describes how to tell a dependency you declare not to automatically import a dependency it needs and will instead rely on you to explicitly declare the dependency or rely on the dependency being imported transitively:它描述了如何告诉您声明的依赖项不要自动导入它需要的依赖项,而是依赖您显式声明依赖项或依赖传递导入的依赖项:

How do I exclude transitive dependencies of something I depend on 如何排除我所依赖的东西的传递依赖

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM