Android依赖关系在发布时被忽略
使用gradle构build项目时,我会收到很多这些警告。 我看到https://stackoverflow.com/a/15794650/864069 ,但我不清楚如何沉默这些。 听起来像这些东西我依赖的任何版本越来越剥夺了在android.jar打包版本的青睐。
我想这没关系,但是我真的想closures这些东西,这样我看到的东西只是真正的问题。
所以,我特别好奇:
- 这是否表明一个问题? 似乎绝对不是。
- 我如何closures这个?
- 不是每个人都看到这一套警告吗? 我怀疑整个使用gradle + android.Log的人都看到了这组警告。
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
我不确定这是否会造成问题。 最好的办法是按照警告中的build议,或完全排除依赖关系(您的要点#2,我已经在下面回答)。
我也看到了这些警告,特别是“公共日志”。
你所链接的线程的答案是说,你应该忽略这些依赖,因为Android API已经包含了它们(我想,如果我错了,纠正我)。
例如,如果您特别要求公用logging(或另一个提供类似警告),请将其从列表中删除。
build.gradle文件:
dependencies { ... compile 'commons-logging:commons-logging:1.1.3' #Remove this line; you don't need it. .... }
另外,如果你有一个需要commons-logging作为传递依赖的依赖,你也应该排除它。
例:
dependencies { ... compile 'some.package.that:requires_commons_logging:1.2.3' .... }
变
dependencies { ... compile ('some.package.that:requires_commons_logging:1.2.3') { exclude group: 'commons-logging', module: 'commons-logging' } .... }
完全排除它的简单方法可以通过将其添加到build.gradle文件来完成,而不必在每个依赖项中排除它:
configurations { all*.exclude group: 'commons-logging', module: 'commons-logging' }
最后,要查看依赖关系树(并查看每个依赖关系可以自行导入的哪些依赖项可能会发生冲突,这可能非常有用),请使用以下命令从项目的根目录:
./gradlew :your_module_name:dependencies
如果你想沉默的警告,你必须添加到您的build.gradle每个依赖项:
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
这将是 :
dependencies { ... compile ('some.package.that:requires_commons_logging:1.2.3') { exclude group: 'commons-logging', module: 'commons-logging' } .... }