我正在开发一个 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)
我做了一些谷歌搜索,理解了我为什么会出现错误,但我不确定如何修复它。从我所读的内容来看,ContentType 试图使用 Android 自带的 BasicHeaderValueParser 类,但该类尚未具有 INSTANCE 字段。请帮忙解决吗?
这些是相关的导入:
compile('org.apache.httpcomponents:httpmime:4.3.6') {
exclude module: 'httpclient'
}
compile 'org.apache.httpcomponents:httpcore:4.3.3'