Android项目开发错误锦集-DuplicateFileException

在将eclipse 项目迁移 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’
}
}

Error:Executionfailedfortask’:app:transformResourcesWithMergeJavaResForDebug’

packagingOptions {
exclude ‘META-INF/NOTICE’ // will not include NOTICE file
exclude ‘META-INF/LICENSE’ // will not include LICENSE file
}

编译项目后出现如下错误:

Error:Execution failed for task ‘:app:transformResourcesWithMergeJavaResForUmengDebug’.

com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/maven/com.belerweb/pinyin4j/pom.properties
File1:C:\Users\CYM.gradle\caches\modules-2\files-2.1\com.belerweb\pinyin4j\2.5.0\5a620aedec0f779f2123ba60fd4b74bfbd3e2646\pinyin4j-2.5.0.jar
File2:C:\Users\CYM.gradle\caches\modules-2\files-2.1\com.belerweb\pinyin4j\2.5.0\5a620aedec0f779f2123ba60fd4b74bfbd3e2646\pinyin4j-2.5.0.jar

解决办法:
在build.grade里的android里添加:
packagingOptions {
exclude ‘META-INF/maven/com.belerweb/pinyin4j/pom.xml’
exclude ‘META-INF/maven/com.belerweb/pinyin4j/pom.properties’
}

你可能感兴趣的:(错误锦集)