我的工作在Android上的应用程序。我使用的HttpCore 4.3.3。我得到这个,当我尝试使用 ContentType.parse(字符串)
java.lang.NoSuchFieldError:类型Lorg /阿帕奇/ HTTP /消息/ BasicHeaderValueParser的任何静态字段实例;在课堂上Lorg /阿帕奇/ HTTP /消息/ BasicHeaderValueParser;或其超(声明org.apache.http.message.BasicHeaderValueParser出现在/system/framework/ext.jar)
我已经做了一些谷歌上搜索,我明白为什么我得到的错误,但我不能确定如何解决它。从我读过,好像是的ContentType试图利用自带的Android和那类没有实例字段尚BasicHeaderValueParser的。任何帮助吗?
这些都是相关的进口:
编译('org.apache.httpcomponents:httpmime:4.3.6'){
排除模块:HttpClient的
}
编译org.apache.httpcomponents:的HttpCore:4.3.3
解决方案
不幸的是股票版本的HttpCore不能在Android中使用。请使用的Apache的HttpClient的Android端口其中还包括必要的HttpCore类
编译('org.apache.httpcomponents:httpmime:4.3.6'){
排除模块:HttpClient的
}
编译org.apache.httpcomponents:HttpClient的-安卓4.3.5
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)
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?
These are the relevant imports:
compile('org.apache.httpcomponents:httpmime:4.3.6') {
exclude module: 'httpclient'
}
compile 'org.apache.httpcomponents:httpcore:4.3.3'
解决方案
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'