Reputation: 403
This post provides a more comprehensive guide and steps that can be used as a bookmark.
Encountering importing errors, which the IDE cannot resolve by itself.
Example error
The import org.apache.http.impl.client.HttpClientBuilder cannot be resolved
Upvotes: 0
Views: 6424
Reputation: 403
Importing org.apache.http package can solve all these below errors
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.protocol.HTTP;
In General (Andriod/Eclipse IDE)
Goto http://hc.apache.org/ .
Click on 4.5.1 tar.gz under HttpClient.
Download the jar file and after done download please extract the download folder and goto lib folder.
Now open your project and import all these external jars into your project. Select your android project by selecting the project name. Then press ALT + ENTER to open project properties & click on Java Build Path.
Then click on LIBRARIES > ADD EXTERNAL JARS.
Now select all the JARs under lib folder.
For IntelliJ IDE
File > Project Structure > Project Settings > Libraries
Click the "+" Icon then choose "Java"
Select all the downloaded JARs
Upvotes: 2