Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HttpClient cannot be resolved to a type

Tags:

android

i'm trying to make http request in android

but i got these errors

- HttpClient cannot be resolved to a type

- DefaultHttpClient cannot be resolved to a type

screenshot:

enter image description here

like image 359
Nabi Avatar asked May 08 '15 07:05

Nabi


2 Answers

Delete this line:

import org.apache.http.*;

And Add these:

import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
like image 123
SilentKnight Avatar answered Sep 19 '22 08:09

SilentKnight


This solved the problem for me: click on the project folder, then alt+Enter, go to Java Build Path, Libraries, click on add external Jar, add the .jar file located at "sdk\platforms\android-23\optional\org.apache.http.legacy.jar", go to order and export and click on org.apache.http.legacy.jar, click OK and it will be solved.

like image 30
Nil Avatar answered Sep 18 '22 08:09

Nil