Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using HttpClient 4.x instead of the build-in pre-beta

Is there a way to use in my android project newer version of HttpClient?

I've tried to import + set in build path newer HttpClient jars, my app is compiled without errors in Eclipse but when I run it in a emulator or real device it produces force close because obviously at runtime the app is referencing the build-in library not the 4.1.1... I've read somewhere that there is a way to "repackage" at built time using Maven but I don't have a clue where to start. I will appreciate any directions that may lead me to using 4.1.1 instead of the built-in version.

To give some context: I am trying to port to android existing legacy code which depends on 4.1 features, i.e. I am trying to avoid major rewriting of my old code.

like image 839
Ognyan Avatar asked Dec 06 '25 18:12

Ognyan


1 Answers

This is not strictly possible. You do not control the classloader, and the firmware always wins.

You could use jarjar or something to refactor 4.1.1 into a new package (e.g., ogre.apache.httpclient) that does not conflict with Android's, then change up all your imports to use that package.

like image 77
CommonsWare Avatar answered Dec 08 '25 08:12

CommonsWare



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!