获取 NoSuchFieldError INSTANCE org/apache/http/message/BasicHeaderValueParser [英] Getting NoSuchFieldError INSTANCE org/apache/http/message/BasicHeaderValueParser

查看:28
本文介绍了获取 NoSuchFieldError INSTANCE org/apache/http/message/BasicHeaderValueParser的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发 Android 上的应用.我正在使用 httpcore 4.3.3.当我尝试使用 ContentType.parse(string)

I'm working on an app on Android. I'm using httpcore 4.3.3. I get this when I try to use 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 字段.有什么帮助吗?

I've done some googling and I understand why I'm getting the error, but I'm unsure how to fix it. From what I've read, it seems that ContentType tries to make use of the BasicHeaderValueParser that comes with Android and that class doesn't have the INSTANCE field yet. Any help please?

这些是相关的导入:

compile('org.apache.httpcomponents:httpmime:4.3.6') {
    exclude module: 'httpclient'
}
compile 'org.apache.httpcomponents:httpcore:4.3.3'

推荐答案

遗憾的是,HttpCore 的股票版本无法在 Android 中使用.请使用 Apache HttpClient Android 端口,其中还包括必需的 HttpCore班级

Unfortunately stock versions of HttpCore cannot be used in Android. Please use Apache HttpClient Android Port which also includes requisite HttpCore classes

compile('org.apache.httpcomponents:httpmime:4.3.6') {
    exclude module: 'httpclient'
}
compile 'org.apache.httpcomponents:httpclient-android:4.3.5'

这篇关于获取 NoSuchFieldError INSTANCE org/apache/http/message/BasicHeaderValueParser的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆