怎么用 android studio http

2024-12-18 10:51:51
推荐回答(1个)
回答1:

HttpClient虽然已经被Google抛弃,但是有限项目依然依赖这些库,还得用。我把Httpclient的所有库导入项目后,会产生如下错误。
Error:duplicate files during packaging of APK F:\Downloads\MyApplication7\app\build\outputs\apk\app-debug-unaligned.apk
Path in archive: META-INF/DEPENDENCIES
Origin 1: F:\Downloads\MyApplication7\app\libs\httpclient-4.5.2.jar
Origin 2: F:\Downloads\MyApplication7\app\libs\httpcore-4.4.4.jar
经过查找可以在文件中加入以下代码消除这个问题。

packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'