How to use Legacy Apache in Eclipse in order to support Android M
Asked Answered
S

1

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

Senhorita answered 1/9, 2015 at 9:43 Comment(3)
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.Pattison
@Pattison 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, tySenhorita
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.Simasimah
D
36

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

Dissimilitude answered 1/9, 2015 at 9:49 Comment(5)
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)Senhorita
I really can't guarantee it for you, I have same doubt even though I am using it on Android studioDissimilitude
Ty a lot :) Tomorrow i'll try it on a real device with Android M so i'm going to be sure!Senhorita
Could you please tell me how to add that as a dependency on Eclipse exactly?Overthrow
@wit221 in your libs folder drag the org.apache.http.legacy.jar and you're done!Senhorita

© 2022 - 2024 — McMap. All rights reserved.