com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/NOTICE

时间:2022-05-24 17:44:20

在将vivo eclipse sdk 迁移 android studio  时候报错

Error:Execution failed for task ':vivosdk:transformResourcesWithMergeJavaResForRelease'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/NOTICE
      File1: /Users/dsh/mobile/sdks/androidStudio/fvsdk-vivo/vivosdk/libs/httpmime-4.0.jar
      File2: /Users/dsh/mobile/sdks/androidStudio/fvsdk-vivo/vivosdk/libs/apache-mime4j-0.6.jar

看起来是因为多个 jar 包里包含了同样的文件(NOTICE),导致打包时因为担心相互覆盖问题而提示出错。

解决:

android{
packagingOptions {
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE' } }