Search code examples
androidgradledependencies

Exclude specific dependency from only one flavor


I have many flavors (5 for example) and all of them uses common dependency.

I know how to compile library only for one flavor (flavorImplementation "org.sample:lib:1.0"). But now I need exclude this dependency for one of flavors. I've overrode dependency packages with stubs in flavor, but dependency still compiles for this flavor.


Solution

  • Instead of all*exclude group:'groupId',module:'moduleId',you can specify only exclude dependency for one flavor like this:

    configurations {
          ...
          flavorImplementation.exclude group:'groupId',module:'moduleId' 
    }
    

    Please replace flavor to your flavorName, and also replace the groupId and moduleId.