HTTPClient 导致应用程序强制关闭

发布于 2024-09-03 02:22:51 字数 1327 浏览 5 评论 0原文

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

老子叫无熙 2024-09-10 02:22:51

你从什么罐子进口的? Apache 客户端是 android 的一部分

正确的包

import org.apache.http.client.HttpClient;

删除您的 jar 并仅使用 SDK 中的库

What jars you've imported from ? Apache client is part of android

Correct package

import org.apache.http.client.HttpClient;

Remove your jars and use only libraries from the SDK

冬天旳寂寞 2024-09-10 02:22:51

没有构造函数“HttpClient()”。

也许你想要这个:

HttpClient client = new DefaultHttpClient();

但是,实际上,如果你想配置它等等,你不能传递一个空的构造函数。阅读文档了解可以传递的不同值。

另外,当您在 stackoverflow 上提出问题时,如果您发布代码以及所收到错误的完整堆栈跟踪,您将获得更多帮助。您可以从 adb logcat 或 eclipse 中获取堆栈跟踪。

There is no constructor "HttpClient()".

Maybe you want this:

HttpClient client = new DefaultHttpClient();

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文