How to use Legacy Apache in Eclipse in order to support Android M-ThrowExceptions

Exception or error:

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

How to solve:

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

Leave a Reply

Your email address will not be published. Required fields are marked *