Kaloyan Roussev
Kaloyan Roussev

Reputation: 14711

Apache httpClient.execute() NoSuchMethodError - project builds ok, but this happens at runtime?

A few days ago I moved my Eclipse project from one folder to another and set up the dependencies again.

The project now builds perfectly and the app runs until it gets to this piece of code:

HttpResponse httpResponse = httpClient.execute(httpPost);

Where I get this error:

Caused by: java.lang.NoSuchMethodError: org.apache.http.impl.client.DefaultHttpClient.execute

In the libs folder I have these jars:

httpclient-4.3.5.jar
httpcore-4.3.2.jar
httpmime-4.3.5.jar

And here is how my Order and export looks like:

enter image description here

And my libraries tab

enter image description here

EDIT: Another thing I tried was downloading the lastest httpcore, httpclient and httpmime and replacing the jars in the libs folder

And I also added them as Add External Jars in Libraries tab of Configure Build path

Upvotes: 0

Views: 1122

Answers (2)

Kaloyan Roussev
Kaloyan Roussev

Reputation: 14711

I resolved my problem by downgrading to versions 4.1 or httpcore, httpclient and httpmime.

Upvotes: 1

Amit Tiwari
Amit Tiwari

Reputation: 3692

I don't have much idea about how you could resolve the error, especially since you seem to be using Eclipse, but as an alternative, you could try OkHttp library. It has very good performance and you could easily modify your codebase with this change.

Upvotes: 0

Related Questions