原因:java.lang.NoClassDefFoundError:org.apache.http.util.Args
它在运行4.1版操作系统的三星设备上崩溃。在棉花糖Nexus6设备上,它工作得非常好。有什么问题 梯度锉原因:java.lang.NoClassDefFoundError:org.apache.http.util.Args,java,android,noclassdeffounderror,Java,Android,Noclassdeffounderror,它在运行4.1版操作系统的三星设备上崩溃。在棉花糖Nexus6设备上,它工作得非常好。有什么问题 梯度锉 conn.addRequestProperty(entity.getContentType().getName(), entity.getContentType().getValue()); 我的libs文件夹中有httpclient-4.3.3.jar httpclient-cache-4.3.3.jar httpcore-4.3.2.jar HttpTime-4.3.3.jar自从
conn.addRequestProperty(entity.getContentType().getName(), entity.getContentType().getValue());
我的libs文件夹中有httpclient-4.3.3.jar
httpclient-cache-4.3.3.jar
httpcore-4.3.2.jar
HttpTime-4.3.3.jar自从marshmallow之后,Apache http客户端被删除 看这里 解决方案(关于嵌入式客户端): 更新: 关于特定问题,请参见相关内容
顺便说一句,在我的项目中,我无法将apache http客户端添加为库,因为包名与embed cliend冲突。我必须使用或如上所述删除Marshmallow Apache HTTP客户端
android {
useLibrary 'org.apache.http.legacy'
}
}
试试这个
app/build/libs Files>>项目结构>>依赖项>>+>>文件依赖项>>然后将其更改为提供而不是编译(如果导入太多JAR,则编译将导致java退出,值为非零值1)
三星已经定制了sdk,因此有可能包含更多的JAR。请像这样包含useLibrary url
android {
useLibrary 'org.apache.http.legacy'
它在棉花糖上工作,在运行4.1的三星上不工作。没有其他方法它在棉花糖上工作,在运行4.1的三星上不工作。没有其他方法调用
compile'org.apache.httpcomponents:httpcore:4.4.1'compile'org.apache.httpcomponents:httpclient:4.5'
此版本而不是yours@user3278732面对同样的问题吗?是的,当然不是帮助。问题出在操作系统为4.1的三星设备上,而不是棉花糖设备。@user3278732您解决了吗?问题出在操作系统为4.1的三星设备上,而不是棉花糖设备。问题出在操作系统为4.1的三星设备上,而不是棉花糖设备。这篇文章很有帮助。编译组:'org.apache.httpcomponents',name:'httpclient android',version:'4.3.5.1'compile('org.apache.httpcomponents:httpime:4.3'){exclude module:'httpclient'}这解决了问题,而不是我将jar文件包含在libs文件夹中
android {
useLibrary 'org.apache.http.legacy'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
useLibrary 'org.apache.http.legacy'