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.
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.
精彩评论