fre*_*k13 8 java apache android http
我正在尝试使用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'
Run Code Online (Sandbox Code Playgroud)
我收到以下错误警告,导致库未导入:
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
Run Code Online (Sandbox Code Playgroud)
任何想法我需要做什么,所以我可以成功导入这些库?
从命令行使用 gradle 进行构建就可以了。
./gradlew installDebug
Run Code Online (Sandbox Code Playgroud)
然后你会看到Android Studio给出的提示只是一个警告:
警告:快照的依赖项 org.apache.httpcomponents:httpclient:4.3.4 将被忽略,因为它可能与 Android 提供的内部版本冲突。如果出现问题,请用jarjar重新打包,更改类包
--- 这里有一些额外的内容,以防您遇到与 apache-http 有关的另一个问题 ---
就我而言,由于 android-gradle-plugin 的错误,我也必须添加一些打包选项:
android {
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
}
}
Run Code Online (Sandbox Code Playgroud)
有关此问题的更多信息,请查看此票证 -> /sf/ask/1447153781/。
| 归档时间: |
|
| 查看次数: |
2411 次 |
| 最近记录: |