首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >发布时忽略Android依赖项。

发布时忽略Android依赖项。
EN

Stack Overflow用户
提问于 2014-08-13 19:59:23
回答 2查看 21.3K关注 0票数 44

在用gradle构建我的项目时,我会收到很多这样的警告。我看到了https://stackoverflow.com/a/15794650/864069,但我不清楚如何让这些人闭嘴。听起来,我所依赖的这些东西的任何版本都是为了支持在android.jar中打包的版本而被剥离掉的。

我想这没什么,但我真的想把这些关起来,这样我看到的东西才是真正的问题。

所以,我很好奇:

  1. 这说明问题了吗?看来绝对不是。
  2. 我该怎么闭嘴?
  3. 不是每个人都看到这一组警告吗?我对使用gradle + android.Log的人是否看到了这组警告表示怀疑。

代码语言:javascript
复制
WARNING: Dependency commons-logging:commons-logging:1.1.1 is ignored for debug as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency commons-logging:commons-logging:1.1.1 is ignored for debug as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency commons-logging:commons-logging:1.1.1 is ignored for release as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency commons-logging:commons-logging:1.1.1 is ignored for release as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency commons-logging:commons-logging:1.1.1 is ignored for debugTest as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency commons-logging:commons-logging:1.1.1 is ignored for debugTest as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency commons-logging:commons-logging:1.1.1 is ignored for robolectric as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency commons-logging:commons-logging:1.1.1 is ignored for robolectric as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency commons-logging:commons-logging:1.1.1 is ignored for debug as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency commons-logging:commons-logging:1.1.1 is ignored for debug as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency commons-logging:commons-logging:1.1.1 is ignored for release as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency commons-logging:commons-logging:1.1.1 is ignored for release as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency commons-logging:commons-logging:1.1.1 is ignored for debugTest as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency org.apache.httpcomponents:httpclient:4.0.3 is ignored for debugTest as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
EN

回答 2

Stack Overflow用户

发布于 2014-08-22 18:36:24

我不确定这会不会产生问题。最好的做法是遵循警告中的建议,或者完全排除依赖(您的第2点,我已经在下面回答了)。

我也看到了这些警告,特别是“共用日志”的警告。

您所链接的线程中的答案是,您应该忽略这些依赖项,因为Android已经包含了这些依赖项(我认为)。如果我错了,请纠正我。

例如,如果您特别需要公用日志记录(或提供类似警告的其他日志记录),则将其从列表中删除。

build.gradle文件:

代码语言:javascript
复制
dependencies {
    ...
    compile 'commons-logging:commons-logging:1.1.3' #Remove this line; you don't need it.
    ....
}

另外,如果您有一个依赖项,需要将公用日志记录作为一个传递依赖项,那么也应该将它排除在外。

示例:

代码语言:javascript
复制
dependencies {
    ...
    compile 'some.package.that:requires_commons_logging:1.2.3'
    ....
}

变成了

代码语言:javascript
复制
dependencies {
    ...
    compile ('some.package.that:requires_commons_logging:1.2.3') {
        exclude group: 'commons-logging', module: 'commons-logging'
    }
    ....
}

完全排除它的一种简单方法也可以通过将其添加到build.gradle文件中来完成,而不必在每个依赖项中排除它:

代码语言:javascript
复制
configurations {
    all*.exclude group: 'commons-logging', module: 'commons-logging'
}

最后,要查看依赖树(并查看每个依赖项各自临时导入哪些可以冲突,非常有用),请从项目的根中使用以下命令:

代码语言:javascript
复制
./gradlew :your_module_name:dependencies
票数 86
EN

Stack Overflow用户

发布于 2016-01-25 14:59:44

如果要对警告保持沉默,则必须在build.gradle中为每个依赖项添加以下内容:

代码语言:javascript
复制
exclude group: 'org.apache.httpcomponents', module: 'httpclient'

它将是:

代码语言:javascript
复制
dependencies {
    ...
    compile ('some.package.that:requires_commons_logging:1.2.3') {
        exclude group: 'commons-logging', module: 'commons-logging'
    }
    ....
}
票数 10
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25295066

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档