19

On Android M, Google has completely removed the support of Apache HTTP client.

This might also be the cause for so many apps crashing on Android M.

From the Google Dev resources:

This preview removes support for the Apache HTTP client. If your app is using this client and targets Android 2.3 (API level 9) or higher, use the HttpURLConnection class instead. This API is more efficient because it reduces network use through transparent compression and response caching, and minimizes power consumption. 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' }

Android is moving away from OpenSSL to the BoringSSL library. If you’re using the Android NDK in your app, don't link against cryptographic libraries that are not a part of the NDK API, such as libcrypto.so and libssl.so. These libraries are not public APIs, and may change or break without notice across releases and devices. In addition, you may expose yourself to security vulnerabilities. Instead, modify your native code to call the Java cryptography APIs via JNI or to statically link against a cryptography library of your choice.

I'm using Eclipse and I don't have Gradle, is there any workaround for this?

I really need to update an app pretty quickly but I can't port it to Android Studio right now

LS_
  • 6,763
  • 9
  • 52
  • 88
  • That may be a problem, Eclipse ADT is deprecated now. The Android team will not be making any changes of that sort for Eclipse. However, you could add the HttpClient library to your App manually and see what happens. – Knossos Sep 01 '15 at 09:46
  • @Knossos it should get the updates until the end of the Year, then it will be no longer supported (at least from what i've read), gonna try that, ty – LS_ Sep 01 '15 at 09:58
  • So I spent hours upgrading via a new HttpClient jar dropped in my lib (since everything was deprecated), and then ran into this error. Google is killing me. – Stephen McCormick Aug 05 '16 at 21:39

1 Answers1

36

Find org.apache.http.legacy.jar which is in Android/Sdk/platforms/android-23/optional, add it to your dependency.

Derek Fung
  • 8,171
  • 1
  • 25
  • 28
  • Much easier than I thought it would be :P Ty a lot! One last question just to be 100% sure: I tried my app with an emulator running the latest version of Android 6.0 and it works fine, this means that on a real device the app will run the same way right? (I mean, it's not going to have problem using the org.apache.http.legacy.jar library) – LS_ Sep 01 '15 at 10:33
  • 1
    I really can't guarantee it for you, I have same doubt even though I am using it on Android studio – Derek Fung Sep 01 '15 at 11:39
  • Ty a lot :) Tomorrow i'll try it on a real device with Android M so i'm going to be sure! – LS_ Sep 01 '15 at 12:25
  • Could you please tell me how to add that as a dependency on Eclipse exactly? – bkr879 Feb 11 '16 at 06:13
  • 2
    @wit221 in your libs folder drag the org.apache.http.legacy.jar and you're done! – LS_ Feb 15 '16 at 13:28