我试图使用HttpEntity将一个文件发送到服务器。
HttpEntity mpEntity = MultipartEntityBuilder.create().addBinaryBody("file", file, ContentType.create("image/jpeg"), file.getName()).build();
然而,为了使用它,我需要将mime库导入到我的项目中。在我的gradle.build中添加:
compile 'org.apache.httpcomponents:httpmime:4.3.4'我收到以下错误警告,导致库未导入:
WARNING: Dependency org.apache.httpcomponents:httpclient:4.3.4 is ignored for debug as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages有什么想法吗?我需要做什么才能成功导入这些库?
发布于 2014-09-02 13:30:15
使用命令行中的gradle构建将完成此任务。
./gradlew installDebug然后,您将看到Android提供的提示只是一个警告:
警告:Dependencyorg.apache.httpComponents:httpclient:4.3.4在快照中被忽略,因为它可能与Android提供的内部版本冲突。如果出现问题,请用jarjar重新打包,以更改类包。
--这里有一些额外的东西,以防你遇到另一个与apache有关的问题--http--
在我的例子中,由于android plugin的一个bug,我不得不添加一些打包选项:
android {
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
}
}有关此问题的更多信息,请查看此票证-> https://stackoverflow.com/questions/20673625/android-gradle-plugin-0-7-0-duplicate-files-during-packaging-of-apk。
https://stackoverflow.com/questions/24997381
复制相似问题