HTTPClient 导致应用程序强制关闭
我在 Android 模拟器上收到此错误:
抱歉 应用程序意外停止。请再试一次。 [强制关闭]
我认为产生错误的代码是这样的: HttpClient client = new HttpClient();
我已从 JARS 导入以下内容:
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.methods.PostMethod;
有什么想法吗?有没有办法获得有关错误的更多详细信息?上面描述的消息不是很有帮助...
Stacktrace:
我已经看过这个,我认为这就是问题所在。 (太长了,无法在此发布所有内容。)
E/dalvikvm( 757): Could not find class 'org.apache.commons.httpclient.HttpClient', referenced from method com.projectNoble.androidClient.serverComms.initCommunication
W/dalvikvm( 757): VFY: unable to resolve new-instance 46 (Lorg/apache/commons/httpclient/HttpClient;) in Lcom/projectNoble/androidClient/serverComms;
W/dalvikvm( 757): VFY: rejecting opcode 0x22 at 0x0000
W/dalvikvm( 757): VFY: rejected Lcom/projectNoble/androidClient/serverComms;.initCommunication ()Ljava/lang/String;
W/dalvikvm( 757): Verifier rejected class Lcom/projectNoble/androidClient/serverComms;
D/AndroidRuntime( 757): Shutting down VM
源代码
可以在本页底部找到: http://hc.apache.org/httpclient-3.x/tutorial。 html
I get this error on my Android emulator:
Sorry
The application has stopped unexpectedly. Please try again. [Force Close]
I think the code that is creating the error is this:
HttpClient client = new HttpClient();
I have imported the following from JARS:
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.methods.PostMethod;
Any idea? Is there a way to get more details on what the error is? The message described above isn't very helpful...
Stacktrace:
I've looked at this and I think this is the problem. (it was too long to post all on here..)
E/dalvikvm( 757): Could not find class 'org.apache.commons.httpclient.HttpClient', referenced from method com.projectNoble.androidClient.serverComms.initCommunication
W/dalvikvm( 757): VFY: unable to resolve new-instance 46 (Lorg/apache/commons/httpclient/HttpClient;) in Lcom/projectNoble/androidClient/serverComms;
W/dalvikvm( 757): VFY: rejecting opcode 0x22 at 0x0000
W/dalvikvm( 757): VFY: rejected Lcom/projectNoble/androidClient/serverComms;.initCommunication ()Ljava/lang/String;
W/dalvikvm( 757): Verifier rejected class Lcom/projectNoble/androidClient/serverComms;
D/AndroidRuntime( 757): Shutting down VM
Source Code
Can be found at bottom of this page:
http://hc.apache.org/httpclient-3.x/tutorial.html
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你从什么罐子进口的? Apache 客户端是 android 的一部分
正确的包
删除您的 jar 并仅使用 SDK 中的库
What jars you've imported from ? Apache client is part of android
Correct package
Remove your jars and use only libraries from the SDK
没有构造函数“HttpClient()”。
也许你想要这个:
但是,实际上,如果你想配置它等等,你不能传递一个空的构造函数。阅读文档了解可以传递的不同值。
另外,当您在 stackoverflow 上提出问题时,如果您发布代码以及所收到错误的完整堆栈跟踪,您将获得更多帮助。您可以从
adb logcat
或 eclipse 中获取堆栈跟踪。There is no constructor "HttpClient()".
Maybe you want this:
really, though, if you want to configure it at all, etc, you can't pass an empty constructor. Read the documentation for the different values you can pass.
Also, when you ask a question on stackoverflow, you'll get a lot more help if you post your code, and the full stacktrace of the error you're getting. You can get the stacktrace from
adb logcat
, or from in eclipse.