无法解析静态字段....使用时HttpClientBuilder [英] Unable to resolve static field....when using HttpClientBuilder

查看:782
本文介绍了无法解析静态字段....使用时HttpClientBuilder的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是想用这条线code的创建HttpClient的实例:

I was trying to create an httpClient instance with this line of code:

HttpClient httpClient = HttpClientBuilder.create().build();

编译是好的,但执行code的时候,我得到了这些错误

Compiling is ok but when the code is executed, I got these errors

D/dalvikvm(21590): DexOpt: couldn't find static field Lorg/apache/http/impl/DefaultConnectionReuseStrategy;.INSTANCE
W/dalvikvm(21590): VFY: unable to resolve static field 5520 (INSTANCE) in Lorg/apache/http/impl/DefaultConnectionReuseStrategy;
D/dalvikvm(21590): VFY: replacing opcode 0x62 at 0x0109
D/dalvikvm(21590): DexOpt: couldn't find static field Lorg/apache/http/impl/client/DefaultConnectionKeepAliveStrategy;.INSTANCE
W/dalvikvm(21590): VFY: unable to resolve static field 5720 (INSTANCE) in Lorg/apache/http/impl/client/DefaultConnectionKeepAliveStrategy;
D/dalvikvm(21590): VFY: replacing opcode 0x62 at 0x0111
D/dalvikvm(21590): DexOpt: couldn't find static field Lorg/apache/http/impl/client/DefaultUserTokenHandler;.INSTANCE
W/dalvikvm(21590): VFY: unable to resolve static field 5758 (INSTANCE) in Lorg/apache/http/impl/client/DefaultUserTokenHandler;
D/dalvikvm(21590): VFY: replacing opcode 0x62 at 0x012f
D/dalvikvm(21590): DexOpt: couldn't find static field Lorg/apache/http/impl/NoConnectionReuseStrategy;.INSTANCE
W/dalvikvm(21590): VFY: unable to resolve static field 5538 (INSTANCE) in Lorg/apache/http/impl/NoConnectionReuseStrategy;
D/dalvikvm(21590): VFY: replacing opcode 0x62 at 0x01b4
D/dalvikvm(21590): DexOpt: couldn't find static field Lorg/apache/http/impl/DefaultConnectionReuseStrategy;.INSTANCE
W/dalvikvm(21590): VFY: unable to resolve static field 5520 (INSTANCE) in Lorg/apache/http/impl/DefaultConnectionReuseStrategy;
D/dalvikvm(21590): VFY: replacing opcode 0x62 at 0x01b8
I/dalvikvm(21590): Could not find method org.apache.http.client.protocol.RequestDefaultHeaders.<init>, referenced from method org.apache.http.impl.client.HttpClientBuilder.build
W/dalvikvm(21590): VFY: unable to resolve direct method 15073: Lorg/apache/http/client/protocol/RequestDefaultHeaders;.<init> (Ljava/util/Collection;)V
D/dalvikvm(21590): VFY: replacing opcode 0x70 at 0x01f0
D/dalvikvm(21590): DexOpt: couldn't find static field Lorg/apache/http/impl/client/DefaultHttpRequestRetryHandler;.INSTANCE
W/dalvikvm(21590): VFY: unable to resolve static field 5721 (INSTANCE) in Lorg/apache/http/impl/client/DefaultHttpRequestRetryHandler;
D/dalvikvm(21590): VFY: replacing opcode 0x62 at 0x02db
D/dalvikvm(21590): DexOpt: unable to opt direct call 0x49b4 at 0x212 in Lorg/apache/http/impl/client/HttpClientBuilder;.build
I/dalvikvm(21590): Could not find method org.apache.http.conn.routing.HttpRoute.getLocalSocketAddress, referenced from method org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect
W/dalvikvm(21590): VFY: unable to resolve virtual method 15468: Lorg/apache/http/conn/routing/HttpRoute;.getLocalSocketAddress ()Ljava/net/InetSocketAddress;
D/dalvikvm(21590): VFY: replacing opcode 0x6e at 0x0020
D/dalvikvm(21590): DexOpt: couldn't find static field Lorg/apache/http/message/BasicLineFormatter;.INSTANCE
W/dalvikvm(21590): VFY: unable to resolve static field 6374 (INSTANCE) in Lorg/apache/http/message/BasicLineFormatter;
D/dalvikvm(21590): VFY: replacing opcode 0x62 at 0x0008
W/dalvikvm(21590): Exception Ljava/lang/NoSuchFieldError; thrown while initializing Lorg/apache/http/impl/io/DefaultHttpRequestWriterFactory;
W/dalvikvm(21590): Exception Ljava/lang/NoSuchFieldError; thrown while initializing Lorg/apache/http/impl/conn/ManagedHttpClientConnectionFactory;
I/JPTFB   (21590): WebView Console: ERROR -  

我把所有的库包括:
HttpClient的-4.3.3.jar
的HttpCore-4.3.2.jar
httpmime-4.3.3.jar
的commons-logging-1.1.3.jar

#

I have all of the libraries included: httpclient-4.3.3.jar httpcore-4.3.2.jar httpmime-4.3.3.jar commons-logging-1.1.3.jar

任何帮助或建议将是AP preciated。

Any help or suggestion would be appreciated.

推荐答案

我有同样的问题,当我试图使用Apache HTTP库的桌面Java版本在Android项目。对我来说,解决方案是简单地诉诸库的Andr​​oid编译(可在谷歌code ++项目网站)。确保事后删除旧的进口,并从库中的版本替换它们。

I had the same problem when I tried to use the desktop Java versions of the Apache HTTP libraries in an Android project. The solution for me was to simply resort to the Android build of the library (available at the Google Code project site). Make sure to remove the old imports afterwards and replace them by the versions from the library.

这篇关于无法解析静态字段....使用时HttpClientBuilder的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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