Resolve incompatiblities of httpclient/httpcore/httpmime jars

1. Question

        When I use httpclient.jar, httpcore.jar and httpmime.jar in my APP development for Android, I encountered below several errors during the APP runs on Android4.4 device.  

(1) Could not find class 'javax.naming.ldap.LdapName'
(2) java.lang.NoSuchFieldError: org.apache.http.message.BasicLineFormatter.INSTANCE
(3) java.lang.VerifyError: org/apache/http/conn/ssl/DefaultHostnameVerifier

 

2. Analysis:

        Through analyzing the debug log, I can confirm all these errors occurred during creating the httpclient object.

 

3. Resolution 

        Firstly, we should choose the proper and compatible versions of corresponding three jars. I finally use httpclient-4.3.6.jar, httpmime-4.3.6.jar, and httpcore-4.3.3.jar.
        Secondly, use DefaultHttpClient() function to get a HttpClient object.

 

 4.  Summarize knowledge

      httpclient/httpcore/httpmime these three tools are already nearly abandoned in current Java and Android version, so it is not recommended to use them in your new project. If necessary, you should keep the versions compatible, and choose proper invoke functions.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值