Clark Ngo
Clark Ngo

Reputation: 403

Resolve "importing org.apache.http package" errors

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

Answers (1)

Clark Ngo
Clark Ngo

Reputation: 403

Source: https://www.android-examples.com/the-import-org-apache-http-httpresponce-cannot-resolved-error-solution/

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)

  1. Goto http://hc.apache.org/ .

  2. Click on 4.5.1 tar.gz under HttpClient.

  3. Download the jar file and after done download please extract the download folder and goto lib folder.

  4. 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.

  5. Then click on LIBRARIES > ADD EXTERNAL JARS.

  6. Now select all the JARs under lib folder.

For IntelliJ IDE

  1. File > Project Structure > Project Settings > Libraries

  2. Click the "+" Icon then choose "Java"

  3. Select all the downloaded JARs

Upvotes: 2

Related Questions