android http 1.1,android – Volley 1.1依赖于org.apache.http

据我所知,https://github.com/google/volley/wiki/Migrating-from-Apache-HTTP volley 1.1删除了对org.apache.http的强制依赖.和

“Most apps using HurlStack or Volley#newRequestQueue with

minSdkVersion set to 9 or higher should not need to take any action

other than removing the useLibrary ‘org.apache.http.legacy’ declaration from your build.gradle file if it is present.”

我没有在任何地方使用org.apache.http,但是当我尝试在单元测试中执行Volley.newRequestQueue(context.getApplicationContext())或新的HurlStack()时,我得到:

java.lang.NoClassDefFoundError: org/apache/http/StatusLine

在运行时.检查HurlStack类我看到它继承自BaseHttpStack,它显然仍然依赖于org.apache.http

import org.apache.http.ProtocolVersion;

import org.apache.http.StatusLine;

import org.apache.http.entity.BasicHttpEntity;

import org.apache.http.message.BasicHeader;

import org.apache.http.message.BasicHttpResponse;

import org.apache.http.message.BasicStatusLine;

所以,我没有得到它,我是否应该包括org.apache.http如果使用带有api级别的凌空> 23或不?

如果我将它包含在build.gradle中,测试运行正常:

testImplementation "org.apache.httpcomponents:httpclient:4.5.5"

注意:

这不是关于NoClassDefFoundError的一般性问题,它特别关注Volley在指令(阅读帖子上的链接)说不应该抛出此异常时抛出此异常.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值