我在Windows 8上使用Android Studio 2.3.2,并且在构建应用程序时发生错误。
首先,在启动IDE的gradle构建过程中,出现以下警告:
Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.3.6 is
ignored for debug as it may be conflicting with the internal version
provided by Android.
Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.3.6 is
ignored for release as it may be conflicting with the internal version
provided by Android.
Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.3.6 is
ignored for debugAndroidTest as it may be conflicting with the internal
version provided by Android.
Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.3.6 is
ignored for debug as it may be conflicting with the internal version
provided by Android.
Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.3.6 is
ignored for release as it may be conflicting with the internal version
provided by Android.
然后在apk生成期间有2条警告和此错误:
Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.3.6 is
ignored for release as it may be conflicting with the internal version
provided by Android.
Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.3.6 is
ignored for debug as it may be conflicting with the internal version
provided by Android.
Error:Execution failed for task
':app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException:
com.android.builder.packaging.DuplicateFileException: Duplicate files copied
in APK META-INF/LICENSE
File1: C:\Users\giorgia\.gradle\caches\modules-2\files-
2.1\com.fasterxml.jackson.core\jackson-
core\2.2.3\1a0113da2cab5f4c216b4e5e7c1dbfaa67087e14\jackson-core-2.2.3.jar
File2: C:\Users\giorgia\.gradle\caches\modules-2\files-
2.1\com.fasterxml.jackson.core\jackson-
annotations\2.2.3\527fece4f23a457070a36c371a26d6c0208e1c3\jackson-
annotations-2.2.3.jar
File3: C:\Users\giorgia\.gradle\caches\modules-2\files- 2.1\org.apache.httpcomponents\httpmime\4.3.6\cf8bacbf0d476c7f2221f861269365b664
47f7ec\httpmime-4.3.6.jar
File4: C:\Users\giorgia\.gradle\caches\modules-2\files-
2.1\com.fasterxml.jackson.core\jackson-
databind\2.2.3\3ae380888029daefb91d3ecdca3a37d8cb92bc9\jackson-databind-
2.2.3.jar
File5: C:\Users\giorgia\.gradle\caches\modules-2\files- 2.1\org.apache.httpcomponents\httpcore\4.4.3\e876a79d561e5c6207b78d347e198c8c45
31a5e5\httpcore-4.4.3.jar
最佳答案
在buildToolsVersion之后,您需要在“应用” build.gradle文件中使用packaginOptions:
packagingOptions {
exclude 'META-INF/LICENSE'
}
关于android - 在Android Studio中构建APK时出现DuplicateFileException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44107751/