问题
Using and Choosing way to make HTTP(S) requests on Android is a long-time pain.
Although Google wants us to use HttpURLConnection, there are those who prefer to use HttpClient instead.
There is this library, https://code.google.com/p/httpclientandroidlib/ with packaging script.
I'd rather use something more integrated with Android build environment.
Is there possibility to use Gradle to repackage Maven dependency (whole tree, including httpclient, httpcomponents, httpmime, ...) in the same way httpclientandroidlib does?
The best scenario would be to have gradle download,repackage and link those libraries in the same transparent way.
gradle:
dependencies {
compile 'org.apache.httpcomponents:httpclient:4.2.3'
compile 'org.apache.httpcomponents:httpmime:4.2.3'
}
回答1:
Simple repackaging from org.apache.http to some other namespace has a drawback of rendering HttpClient incompatible with 3rd party libraries compiled against the stock APIs. There are plans to create a re-spin of HttpClient 4.3 specifically for Android fully compatible with 4.0 BETA1 APIs and with most of 4.3 features back-ported to it. It is a shame really that the way of mitigating the damage of Android's fork of HttpClient appears to be by creating yet another fork. Thank you Google.
NEW INFO
Apache HttpComponents created spin of HttpClient library for Android only, which is available here: https://hc.apache.org/httpcomponents-client-4.3.x/android-port.html
来源:https://stackoverflow.com/questions/19361128/gradle-rename-maven-dependency-package-httpcomponents-android