To continue using the Apache HTTP APIs, you must first declare the following compile-time dependency in your build.gradle file:
android {
useLibrary 'org.apache.http.legacy'
}
Have to sync Gradle project after you insert the above code in build.gradle file.
Reference: Android 6.0 Changes - Apache HTTP Client Removal
Related examples of using Apache HTTP client and HttpURLConnection:
- Android App to control Standalone ESP8266/ESP-12 on-board LED, using Android 6.0 removed HttpClient
- Android App to control Standalone ESP8266/ESP-12 on-board LED, using HttpURLConnection