Android M移除HttpClient的影响及网络库适用性疑问
Hey there! I totally get why that README line might have thrown you off—let's unpack this clearly so you know exactly what's going on.
First, the core context of Android M's change
Android Marshmallow(Android M)近期移除HttpClient导致其他网络库过时
This statement only tells part of the story. Here's the full picture:
- Android 6.0 (API 23) removed Apache HttpClient from the core Android SDK. This was a deliberate choice by Google, who recommended switching to
HttpURLConnection(or later, OkHttp) for better performance and easier long-term maintenance. - But this only breaks libraries that directly depend on the system-provided Apache HttpClient. It does not make libraries like Volley or Retrofit unusable—far from it.
Let's break down your specific questions:
1. Do Volley and Retrofit stop working on Android M+?
Absolutely not. Here's why:
- Retrofit: By default, Retrofit uses OkHttp as its underlying HTTP client. OkHttp has never relied on Apache HttpClient, so Retrofit works seamlessly on all modern Android versions (including M and above). No compatibility issues here at all.
- Volley: The original Volley had a variant that used HttpClient, but the official Volley library has long been updated to use
HttpURLConnectionby default. Even if you're using an older Volley version, you can still make it work on Android M+ by adding the explicit Apache HttpClient compatibility dependency to yourbuild.gradle:
That said, it's better to upgrade to the latest Volley version, which is fully optimized for modern Android.dependencies { implementation 'org.apache.httpcomponents:httpclient-android:4.3.5.1' }
2. What does that README statement actually mean?
It's referring to older, unmaintained networking libraries built directly on top of the system's Apache HttpClient. Those libraries would fail on Android M+ because the HttpClient classes are no longer present in the SDK. But mainstream, actively maintained libraries like Volley and Retrofit either adapted to use alternative HTTP clients (like HttpURLConnection or OkHttp) or never relied on HttpClient in the first place.
3. About your project's current dependency (c...)
Since you didn't share the full dependency string, here's a quick check:
- If your dependency includes references to
org.apache.httpor explicitly mentions HttpClient, you'll need to either:- Replace it with a modern library (like Retrofit or updated Volley)
- Add the compatibility dependency I mentioned above to keep it working
- If it's a mainstream library like Volley or Retrofit, you're good to go—no changes needed for Android M+ compatibility.
内容的提问来源于stack exchange,提问作者Kennedy Kambo

