【发布时间】:2015-02-06 14:33:21
【问题描述】:
我正在开发一个 Android 应用。我正在使用 httpcore 4.3.3。当我尝试使用 ContentType.parse(string)
java.lang.NoSuchFieldError: No static field INSTANCE of type Lorg/apache/http/message/BasicHeaderValueParser; in class Lorg/apache/http/message/BasicHeaderValueParser; or its superclasses (declaration of 'org.apache.http.message.BasicHeaderValueParser' appears in /system/framework/ext.jar)
我在 Google 上进行了一些搜索,并且了解我收到错误的原因,但我不确定如何解决它。根据我的阅读,似乎 ContentType 试图利用 Android 附带的 BasicHeaderValueParser 并且该类还没有 INSTANCE 字段。请问有什么帮助吗?
这些是相关的导入:
compile('org.apache.httpcomponents:httpmime:4.3.6') {
exclude module: 'httpclient'
}
compile 'org.apache.httpcomponents:httpcore:4.3.3'
【问题讨论】:
-
你在使用 Proguard 吗?
-
我不这么认为。我最近升级到 android studio 1.0,这让你使用 minifyEnabled 而不是 runProguard,我想我把它们设置为 false。我可以尝试将它们设置为 true,但还有其他方法可以解决这个问题吗? --> 好像没有修复
-
使用 jarjar 重新打包 apache http 库或使用旧的 httpmime 库(检查哪个版本与您项目的 minsdk 兼容)
标签: android apache-httpclient-4.x androidhttpclient