Error using apache Httpclient class

Asked

Viewed 600 times

5

I’m trying to develop an app in which will communicate with webservice, but by the time having to use the Httpclient or other classes related to apache library gives error as it does not exist, I have already manually put the files . jar in lib folder but continued to show error.

2 answers

4

In Android version 6.0 (API level 23) customer support has been removed HTTP Apache.

Instead of her use the class Httpurlconnection. This API is more efficient as it reduces network usage and minimizes power consumption.

To continue using Apis from Apache HTTP, you have to declare the following dependency on the file build.Gradle:

android {
    useLibrary 'org.apache.http.legacy'
}

Information obtained here

  • You would have some material to indicate about using the Httpurlconnection class ?

  • See on documentation and this example of use I found searching on google.

  • Who negatived can please explain the reason.

3


Next friend add the following libraries to build.gradle in the block dependencies.

dependencies {
    ...
    compile 'com.google.code.gson:gson:2.2.4'
    compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
  • friend these two libraries mentioned above by me work that and a beauty in all Apis, I have an application created that uses these libraries and the same never generated errors

Browser other questions tagged

You are not signed in. Login or sign up in order to post.