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

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

概述据我所知, 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 s 据我所知,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在指令(阅读帖子上的链接)说不应该抛出此异常时抛出此异常.

解决方法 在AndroID Pi(9)设备的Application标签中的AndroIDManifest文件中使用以下行
<uses-library            androID:name="org.apache.http.legacy"            androID:required="false" />
总结

以上是内存溢出为你收集整理的android – Volley 1.1依赖于org.apache.http全部内容,希望文章能够帮你解决android – Volley 1.1依赖于org.apache.http所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1135209.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存