您的位置:首页 > 移动开发 > Android开发

Android项目开发错误锦集-DuplicateFileException

2016-07-20 16:18 495 查看
在将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’

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息