android - 为什么gradlew :app:dependencyInsight fail?

标签 android gradle android-gradle-plugin build.gradle gradlew

我尝试运行此命令以列出 firebase-messaging 库的所有依赖项:

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

但它会返回我:

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

BUILD SUCCESSFUL in 0s 1 actionable task: 1 executed

这是我的 build.gradle 文件:

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'
}

我做错了什么?

最佳答案

dependencyInsightcompileClasspath 一起使用在 Android 项目上工作得很好(不像 accepted answer 似乎声称的那样)。你只需要在它前面加上完整的 build variant名字!

例如,如果您的项目仅使用构建类型,则使用 debugCompileClasspathreleaseCompileClasspath 作为配置参数。

如果产品 flavor 也在使用中,则形式为 flavorDebugCompileClasspath(插入您自己的 flavor 名称)。

我项目中的一个工作示例(产品风格完整,构建类型调试):

./gradlew app:dependencyInsight --configuration fullDebugCompileClasspath --dependency gson

关于android - 为什么gradlew :app:dependencyInsight fail?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49646103/

相关文章:

java - 尝试关闭蓝牙套接字时,它变为空(错误: null object reference)

android - 网格或相对布局

gradle - 如何将 Ant 片段转换为Gradle

android - 错误 :Execution failed for task ':app:processDebugGoogleServices' . 安卓

java - 将 Cursor 转换为通用对象 android

java - 如何暂停播放并停止来自parse.com(android)的音频文件流?

intellij-idea - 将项目导入Android-Studio

gradle - 如何在非Java构建中声明项目工件?

android - 如果我覆盖 Application 并将 multiDexEnabled 设置为 'true' 会怎样?

android - 在正常和测试编译中添加的 Espresso 依赖项