简体   繁体   中英

Implement multiple library versions with Gradle

I have two libraries, which both include by themself a different version of com.android.billingclient:billing ; 1.2.2 and 2.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?

The key phrase to finding the solution to your problem is: 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.

Check out the discussion of this question in the Gradle Forums, I think it addresses your problem. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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