Start a Project

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

Result1.

 

Case2. When no dependency is added in the main project

Result2.

Case3. When Library Project is Added

Result3.

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

 

Result4.

 

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

 

Result5.

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

 

Result 6:

 

 

 

Exit mobile version