-
Notifications
You must be signed in to change notification settings - Fork 754
Migrating from Apache HTTP
As of Volley version 1.1.0, Apache HTTP has gone from being required to optional in keeping with the library's deprecation in the Android platform. It is only needed for clients using the Apache HttpClientStack. Existing apps should continue to compile and work with no changes, but apps should be able to remove the dependency, potentially after some minor modifications detailed below.
Most apps using HurlStack or Volley#newRequestQueue with minSdkVersion set to 9 or higher should not need to take any action other than removing the useLibrary 'org.apache.http.legacy' declaration from your build.gradle file if it is present.
For apps which need to support Froyo (API 8) devices, Apache HTTP remains the recommended option due to known issues in HttpUrlConnection. You should continue to use HttpClientStack or Volley#newRequestQueue (which uses HttpClientStack on API 8 devices and HurlStack, based on HttpUrlConnection, on newer devices). Your build.gradle file will need to continue specifying useLibrary 'org.apache.http.legacy'. Note that Volley plans to end support for API 8 devices in an upcoming release in keeping with other Android libraries.
Otherwise, migration instructions are as follows:
-
If your app uses a custom
HttpStackimplementation, it will need to be migrated toBaseHttpStack. This will entail renaming theperformRequestmethod toexecuteRequestand changing the return type from Apache'sHttpResponseclass to Volley's newHttpResponseclass. Your code should never callperformRequestdirectly. -
If your app extends BasicNetwork, the protected
mHttpStackfield andconvertHeadersmethod have been deprecated and must not be used. Otherwise, be sure to use the new constructors which takeBaseHttpStackimplementations rather thanHttpStackimplementations. -
If your app uses
Volley#newRequestQueue, be sure you are passing in aBaseHttpStackinstance and not anHttpStackinstance.