Gradle: excluding dependencies


There are situation in modular approach when you want to exclude some of the dependency from that the library project used. This happens because of many reason. Either we use a latest dependency or we have transitive dependency issue.


In this blog we are going to watch how dependencies are excuded from library project.


Let Us first create two project

  1. GradleDemo (our main project)
  2. MyLibrary (Android Library project)


Let us save following dependency in MyLibrary


Now let us draw dependency tree hierarchy on different case.

Note: we can draw dependency tree graph using android studio terminal (command prompt) by following command

 gradle app:dependencies

or use gradle –gui for graphic user interface.

Case 1. When no library project is Added



Case2. When no dependency is added in the main project


Case3. When Library Project is Added


Case4. Excluding a group of dependency from our library project when building our main project




Case5. Excluding a module from a group of dependency from our library project when building our main project



Case 6: When same dependencies are present in the library project


Result 6:




. . .

Leave a Comment

Your email address will not be published. Required fields are marked*

Be the first to comment.


Great Product, Great Team, and Great Support Service. And if you want to add more features to the product, they can submit any idea that comes to your mind. They really care about their clients and we are really happy and honored to deal with Webkul.

Talk to Sales


Live Chat
Start a Project

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home