Why did gradlew :app:dependencyInsight fail?
Asked Answered
T

2

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 ?

Tomikotomkiel answered 4/4, 2018 at 8:23 Comment(0)
B
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

Boehm answered 4/4, 2018 at 9:46 Comment(7)
I update your answer to put in it the output of the command line ... as you see it's not work :(Tomikotomkiel
Weird thing to do... I updated my answer with a different commandBoehm
now i have "Configuration with name 'compileClasspath' not found."Tomikotomkiel
According to this answer ( https://mcmap.net/q/56180/-not-able-to-copy-configurations-dependencies-after-upgrading-gradle-plugin-for-android-studio-to-3-0-1-and-gradle-to-4-1 ) it won't work on Android, unless you use the old deprecated compile configuration :/Boehm
You can use the plain old gradle dependencies and look for firebase-messaging inside the result. Less convenient but will work.Boehm
thanks @Boehm ... I updated your answer again, because even with using deprecated compile still not work :(Tomikotomkiel
You can use --configuration implementation but with suffix "DependenciesMetadata" to show with transitive stuff. e.g. gradlew app:dependencies --configuration implementationDependenciesMetadataElata
U
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
Unfeeling answered 30/4, 2020 at 19:2 Comment(2)
This answer was useful (after fixing a key typo in it) in figuring this out.Unfeeling
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 prodDebugTestCompileClasspathRentier
B
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

Boehm answered 4/4, 2018 at 9:46 Comment(7)
I update your answer to put in it the output of the command line ... as you see it's not work :(Tomikotomkiel
Weird thing to do... I updated my answer with a different commandBoehm
now i have "Configuration with name 'compileClasspath' not found."Tomikotomkiel
According to this answer ( https://mcmap.net/q/56180/-not-able-to-copy-configurations-dependencies-after-upgrading-gradle-plugin-for-android-studio-to-3-0-1-and-gradle-to-4-1 ) it won't work on Android, unless you use the old deprecated compile configuration :/Boehm
You can use the plain old gradle dependencies and look for firebase-messaging inside the result. Less convenient but will work.Boehm
thanks @Boehm ... I updated your answer again, because even with using deprecated compile still not work :(Tomikotomkiel
You can use --configuration implementation but with suffix "DependenciesMetadata" to show with transitive stuff. e.g. gradlew app:dependencies --configuration implementationDependenciesMetadataElata

© 2022 - 2024 — McMap. All rights reserved.