【问题标题】:Android app level build.gradle giving Error : httpclient defines classes that conflict with classes now provided by AndroidAndroid 应用程序级别 build.gradle 给出错误:httpclient 定义的类与 Android 现在提供的类冲突
【发布时间】:2021-12-08 18:58:04
【问题描述】:

在我的一个旧项目中,我在应用级 build.gradle 文件中收到此错误/建议:

httpclient 定义了与 Android 现在提供的类冲突的类。解决方案包括查找没有相同问题的较新版本或替代库(例如,对于 httpclient,请改用 HttpUrlConnection 或 okhttp),或使用 jarjar 之类的东西重新打包库。

查看下面的截图:

似乎错误是由于依赖org.apache.httpcomponents:httpmime:4.5.12

我试图通过互联网找到解决方案。试过1,2,3,但没有任何帮助。

任何帮助将不胜感激。

【问题讨论】:

  • 尝试从中排除httpclient。像这样的东西 - implementation ('org.apache.httpcomponents:httpmime:4.5.12') { exclude group: 'org.apache.httpcomponents', module: 'httpclient' }
  • 我已经尝试过了,但它用于我的网络操作,所以网络类在这样做后会出错。

标签: android android-studio build.gradle apache-httpcomponents


【解决方案1】:

我通过添加implementation "org.apache.httpcomponents:httpcore:4.4.13" 并排除group: 'org.apache.httpcomponents', module: 'httpclient' 解决了这个问题

检查一下:

implementation('org.apache.httpcomponents:httpmime:4.5.12') {
    exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}
implementation "org.apache.httpcomponents:httpcore:4.4.13"

【讨论】:

    猜你喜欢
    • 2019-06-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-09
    • 2018-10-22
    • 1970-01-01
    • 1970-01-01
    • 2012-09-23
    相关资源
    最近更新 更多