tyczj
tyczj

Reputation: 74056

Duplicate gradle dependencies always compiled?

If i have say the appcompat-v7 dependency in my build.gradle and then I have another dependency that also uses the appcompat-v7 library are both of those compiled or is just one compiled and the other is ignored?

Reason I ask is I ran the gradle command that gives you your dependency tree and there were a lot of duplicated dependencies that are in other libraries but already declared in my app

Upvotes: 0

Views: 232

Answers (1)

Benjamin
Benjamin

Reputation: 7368

Gradle resolves the dependencies according to some rules:

  1. If they have the same version number, there is no problem and the dependency is added once with the given version number.

  2. If they are imported twice with different version number, gradle uses a default conflict strategy to choose the "best one".

In all case, a given library is always added only once.

Upvotes: 4

Related Questions