How to use library with different version then one

2019-08-04 10:09发布

问题:

I want to use the latest HttpClient 4.1 version in my application. But Android already bundled with HttpClient.

The only way that I see is to build this library from sources, and change package name.

Is there any other solution?

EDIT:

At download page I see OSGi bundle. I have no experience in using OSGi, but AFAIK, OSGi intended to solve libraries versioning problems? If so, how can I use it?

回答1:

You can use the Maven Shade Plugin to move all classes to a different package and then use it from there. http://maven.apache.org/plugins/maven-shade-plugin/

If you do that the easiest will be to also build you application with Maven using the Maven Android Plugin http://code.google.com/p/maven-android-plugin/