为什么 gradlew :app:dependencyInsight 失败了?
Why did gradlew :app:dependencyInsight fail?
我尝试运行这个命令来列出 firebase-messaging 库的所有依赖项:
gradlew :app:dependencyInsight --configuration compile --dependency firebase-messaging
但这是 return 我 :
: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'
}
我做错了什么?
那是因为 firebase-messaging
是在 implementation
配置中声明的。 compileClasspath
should be used
尝试:
gradlew :app:dependencyInsight --configuration compileClasspath --dependency firebase-messaging
编辑:使用 compileClasspath
将无法与 Android 一起使用,如 here
所述
使用 gradle :app:dependencies
获取所有依赖项似乎是获取 firebase-messaging
的所有依赖项的更简洁方法
将 dependencyInsight
与 compileClasspath
一起使用在 Android 项目上效果很好(与 seems to claim). You just need to prefix it with the full build variant 名称不同!
例如,如果您的项目仅使用构建,则使用 debugCompileClasspath
或 releaseCompileClasspath
作为配置参数类型。
如果产品口味也在使用中,则格式为 flavorDebugCompileClasspath
(插入您自己的口味名称)。
我项目中的一个工作示例(产品风格 full
,构建类型 debug
):
./gradlew app:dependencyInsight --configuration fullDebugCompileClasspath --dependency gson
我尝试运行这个命令来列出 firebase-messaging 库的所有依赖项:
gradlew :app:dependencyInsight --configuration compile --dependency firebase-messaging
但这是 return 我 :
: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'
}
我做错了什么?
那是因为 firebase-messaging
是在 implementation
配置中声明的。 compileClasspath
should be used
尝试:
gradlew :app:dependencyInsight --configuration compileClasspath --dependency firebase-messaging
编辑:使用 compileClasspath
将无法与 Android 一起使用,如 here
使用 gradle :app:dependencies
获取所有依赖项似乎是获取 firebase-messaging
将 dependencyInsight
与 compileClasspath
一起使用在 Android 项目上效果很好(与
例如,如果您的项目仅使用构建,则使用 debugCompileClasspath
或 releaseCompileClasspath
作为配置参数类型。
如果产品口味也在使用中,则格式为 flavorDebugCompileClasspath
(插入您自己的口味名称)。
我项目中的一个工作示例(产品风格 full
,构建类型 debug
):
./gradlew app:dependencyInsight --configuration fullDebugCompileClasspath --dependency gson