5

I have the problem. I have undesired dependency, that is not included explicitly in the gradle file. I cannot figure out how to find which dependency transitively includes this one.

How can I find out where does this dependency come from ?

I have tried

gradlew analyze

But fails to compile my project

Thanks

1 Answers1

7

dependencyInsight task can do this for you. Example:

 gradle -q lib:dependencyInsight --dependency groovy --configuration compile

or for Android

gradlew -q app:dependencyInsight --dependency gson --configuration debugCompileClasspath

Will show why dependency containing groovy in its name is included in compile configuration of the lib project. See this doc section for details

Nikita Skvortsov
  • 4,768
  • 24
  • 37
  • 1
    With gradle 3.0 we have to use construction like this: **gradlew -q app:dependencyInsight --dependency gson --configuration debugCompileClasspath** – zkvarz Nov 07 '17 at 12:36
  • 2
    To find out configurations in your project, run `./gradlew app:androidDependencies`. There all configurations are listed for the `app` module. Although default, `debugCompileClasspath` not always is a configuration in the `app` module (neither is the `app` module always called `app`). – Erik Jun 28 '19 at 11:11