Add Org.Apache.Http.Legacy in Android Studio

Apache library is specially used to add HTTP ( Hyper Text Transfer Protocol ) into android applications. This library provides us the NameValuePair, BasicNameValuePair, HttpClient, HttpPost, HttpResponse methods which will enable us to use the send data on a particular functionality. So here is the step by step tutorial for Add Org.Apache.Http.Legacy in Android Studio.

Major errors found without adding Apache library :

  • Cannot resolve symbol ‘NameValuePair’ .
  • Cannot resolve symbol ‘BasicNameValuePair’ .
  • Cannot resolve symbol ‘HttpClient’ .
  • Cannot resolve symbol ‘DefaultHttpClient’ .
  • Cannot resolve symbol ‘HttpPost’ .
  • Cannot resolve symbol ‘UrlEncodedFormEntity’ .
  • Cannot resolve symbol ‘HttpResponse’ .
  • Cannot resolve symbol ‘HttpEntity’ .
  • Cannot resolve method ‘getEntity()’ .
  • Cannot resolve symbol ‘ClientProtocolException’ .
  • Cannot resolve method ‘execute(HttpPost)’ .

Screenshot of Error :

How to solve Org.Apache.Http.Legacy in not found error Android Studio.

1. Start a new development project in Android Studio or open your current project in which you want to import the library.

2. Click on project’s build.gradle(Module : app) .

3. Add useLibrary ‘org.apache.http.legacy’ in android scope.

Http

Here you go now the Apache library is successfully added into your project.

Leave a Reply

Your email address will not be published. Required fields are marked *