Reputation: 11050
This is the core of the exception:
12-12 10:37:50.090: E/AndroidRuntime(8277): Caused by: java.lang.NoSuchMethodError: org.apache.http.conn.scheme.Scheme.<init>
I'm using Apache httpclient 4.2.2. However, Android has decided that using its bundled outdated Apache httpclient library is a better option.
How can I avoid this exception?
Just in case: Changing the org.apache namespace is not an option since this exception is being thrown by a closed-source library.
Upvotes: 4
Views: 1598
Reputation: 23186
This link might help, it is a repackaging of HttpClient 4.2.3 for Android that you can reference as a library jar / external library in your project:
http://code.google.com/p/httpclientandroidlib/
Upvotes: 0
Reputation: 1007474
However, Android has decided that using its bundled outdated Apache httpclient library is a better option.
Google cares about backwards compatibility. As you are discovering, HttpClient has different APIs with different versions, and so if Google upgraded HttpClient, all existing apps would break. Google needs to maintain a consistent public API, so that apps written for Android 1.x work on Android 4.x and so on. Google, unfortunately, selected a version of HttpClient that resulted in a rapid break with newer HttpClient versions' public APIs.
How can I avoid this exception?
Use jarjar
or the equivalent to refactor your copy of the HttpClient library into a different package name, then use it.
Changing the org.apache namespace is not an option since this exception is being thrown by a closed-source library.
Then replace the closed-source library with something else. Clearly, if the closed-source library requires HttpClient 4.2.2, then that closed-source library will not work on Android and is not supported by its developer on Android. Even if you were to get past the HttpClient problem (e.g., via a ROM mod -- see below), there may well be other issues with this library with respect to its compatibility with Android.
Or, download the Android source code, replace the HttpClient version with your own, build the revised Android source code, pour the results into a ROM mod, and install the ROM mod on your desired device. Along the way, be sure to test any existing apps to make sure they do not break because of your change (most probably use HttpUrlConnection
, but they might not).
Upvotes: 3