12

I try to run this command to list all the dependencies of firebase-messaging library :

gradlew :app:dependencyInsight --configuration compile --dependency firebase-messaging

but it's return me :

:app:dependencyInsight No dependencies matching given input were found in configuration ':app:compile'

BUILD SUCCESSFUL in 0s 1 actionable task: 1 executed

this is my build.gradle file :

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.example.test.myapplication"
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:design:27.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    implementation 'com.google.firebase:firebase-messaging:12.0.1'
}

What i did wrong ?

Jonik
  • 80,077
  • 70
  • 264
  • 372
zeus
  • 12,173
  • 9
  • 63
  • 184

2 Answers2

15

Using dependencyInsight with compileClasspath works just fine on Android projects (unlike what the accepted answer seems to claim). You just need to prefix it with the full build variant name!

For example, use debugCompileClasspath or releaseCompileClasspath as the configuration param if your project only uses build types.

If product flavours are also in use, the form is flavorDebugCompileClasspath (insert your own flavour name).

A working example from my project (product flavour full, build type debug):

./gradlew app:dependencyInsight --configuration fullDebugCompileClasspath --dependency gson
Jonik
  • 80,077
  • 70
  • 264
  • 372
  • [This answer](https://stackoverflow.com/a/46986264/56285) was useful (after fixing a key typo in it) in figuring this out. – Jonik May 13 '20 at 16:30
  • What does the configuration look like for test and androidTest dependencies? tried a few combination based on this answer but can't get it right. e.g ```gradle :base:dependencyInsight --dependency okhttp3 --configuration prodDebugTestCompileClasspath``` – Sushant May 02 '21 at 23:39
7

That's because firebase-messaging is declared in the implementation configuration. compileClasspath should be used

Try :

gradlew :app:dependencyInsight --configuration compileClasspath --dependency firebase-messaging

edit : using compileClasspath won't work with Android as described here

Using gradle :app:dependencies to fetch all dependencies seems to be the cleaner way to get all the dependencies of firebase-messaging

ToYonos
  • 16,469
  • 2
  • 54
  • 70
  • I update your answer to put in it the output of the command line ... as you see it's not work :( – zeus Apr 04 '18 at 09:53
  • Weird thing to do... I updated my answer with a different command – ToYonos Apr 04 '18 at 09:56
  • now i have "Configuration with name 'compileClasspath' not found." – zeus Apr 04 '18 at 09:59
  • According to this answer ( https://stackoverflow.com/a/48913550/2003986 ) it won't work on Android, unless you use the old deprecated `compile` configuration :/ – ToYonos Apr 04 '18 at 10:05
  • You can use the plain old `gradle dependencies` and look for `firebase-messaging` inside the result. Less convenient but will work. – ToYonos Apr 04 '18 at 10:11
  • thanks @ToYonos ... I updated your answer again, because even with using deprecated compile still not work :( – zeus Apr 04 '18 at 10:13
  • You can use --configuration implementation but with suffix "DependenciesMetadata" to show with transitive stuff. e.g. gradlew app:dependencies --configuration implementationDependenciesMetadata – CeH9 Oct 30 '19 at 17:29