【问题标题】:Find lib dependencies with gradle 3.0使用 gradle 3.0 查找 lib 依赖项
【发布时间】:2017-12-12 09:53:53
【问题描述】:

我的 android 项目中有很多库外部库,我想知道它们来自哪里。

我使用命令行:gradlew :app:dependencyInsight --configuration compile --dependency this answer中提到

如上图所示,尝试找到 recyclerview

gradlew :app:dependencyInsight --configuration 编译 --dependency recyclerview

但什么也没找到:

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

BUILD SUCCESSFUL in 1s
1 actionable task: 1 executed

witch 提醒我,我的 build.gradle 文件中没有 app:compile 配置。在 gradle 3.0 之后,compile 已经被 implementationapi 所取代。所以我改变了命令行如下:

gradlew :app:dependencyInsight --配置实现 --dependency recyclerview

但出错了:

FAILURE: Build failed with an exception.
What went wrong:

Execution failed for task ':app:dependencyInsight'.

Resolving configuration 'implementation' directly is not allowed

Try:

Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.
Get more help at https://help.gradle.org

BUILD FAILED in 2s
1 actionable task: 1 executed

我在谷歌上搜索了很多关于这个错误的信息,但找不到答案。 后来我用 build.gradle 文件中的 'compile' 替换了所有的 'implementation',并使用了第一个编译配置命令行,并且成功了。

E:\AndroidApps\SqliteLearn>gradlew :app:dependencyInsight --configuration compile --dependency recyclerview

Configure project :app
Configuration 'compile' in project ':app' is deprecated. Use 'implementation' instead.
... ...

Task :app:dependencyInsight
com.android.support:recyclerview-v7:26.1.0
\--- com.android.support:design:26.1.0
     \--- compile

BUILD SUCCESSFUL in 1s
1 actionable task: 1 executed

上面的命令行似乎只适用于编译配置。 有没有一个命令行可以做同样的工作并与实现配置一起工作?

【问题讨论】:

    标签: android gradle dependencies


    【解决方案1】:

    看看https://docs.gradle.org/current/userguide/userguide_single.html#sec:java_library_configurations_graph,你会发现各种新的配置,它们是可解析的和可消耗的。

    我想你想要的是runtimeElementsruntimeClasspath,不确定哪一个在这种情况下会起作用。

    您也可以使用dependencies 任务而不提供配置,这将解析并显示所有配置及其依赖项。

    【讨论】:

      猜你喜欢
      • 2016-12-20
      • 1970-01-01
      • 1970-01-01
      • 2016-02-10
      • 1970-01-01
      • 2021-10-08
      • 2015-04-23
      • 2011-09-17
      • 2022-12-20
      相关资源
      最近更新 更多