错误描写叙述

今天在Android Studio项目中添加了jackson的开发包,编译执行时候。引发了例如以下的错误:

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/NOTICE
File1: D:\Code\XTCKuwoWatch\app\libs\jackson-core-2.4.4.jar
File2: D:\Code\XTCKuwoWatch\app\libs\jackson-databind-2.4.4.jar

错误截图例如以下所看到的:


解决的方法

看起来是由于多个 jar 包里包括了相同的文件(NOTICE.txt)。导致打包时由于操心相互覆盖问题而提示出错。 尝试下在 app 下的 build.gradle 中的 android 部分添加一段配置。如以下这段代码所看到的:

packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
  • 没改动前的build.gradle文件
apply plugin: 'com.android.application'

android {
compileSdkVersion 22
buildToolsVersion "22.0.1" defaultConfig {
applicationId "com.oyp.csdn"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
} dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}

  • 改动后的build.gradle文件
apply plugin: 'com.android.application'

android {
compileSdkVersion 22
buildToolsVersion "22.0.1" packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
} defaultConfig {
applicationId "com.oyp.csdn"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
} dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
作者:欧阳鹏 欢迎转载,与人分享是进步的源泉!
转载请保留原文地址:http://blog.csdn.net/ouyang_peng

最新文章

  1. 第二天 ci执行流程
  2. firefox浏览器不支持复制粘贴(linux)
  3. mysql 行转列 和 列转行
  4. HTML5和CSS3基础教程(第8版)-读书笔记(2)
  5. BZOJ3503: [Cqoi2014]和谐矩阵
  6. SASS、COMPASS 安装指南
  7. union的用法
  8. 搜索Collections元素,用DateFormatSymbols 获得月份
  9. [HeadFist-HTMLCSS学习笔记][第五章认识媒体]
  10. html基础标签-1-pre预格式标签
  11. CentOS 安装Chrome
  12. 在容器中运行 Jenkins pipeline 任务
  13. [开源]Dapper Repository 一种实现方式
  14. C#字符串和数组互转
  15. 搞明白GOROOT,GOPATH,GOBIN,project目录
  16. 使用FileZilla连接时超时,无法连接到服务器
  17. 6-16 单词 uva10129
  18. Codeforces.911F.Tree Destruction(构造 贪心)
  19. 20180824 SSRS Line Chart 绘制
  20. curl java 模拟http请求

热门文章

  1. map/set/object/array对比
  2. 都系坤坤-微信助手V 0.1,解放双手发信息
  3. cf671B Robin Hood
  4. 【CF1016B】Segment Occurrences(模拟)
  5. py2exe使用方法 (含一些调试技巧,如压缩email 类)
  6. Win32 绘制RGB三原色图案
  7. 你也可以当面霸-MVC的原理及特点
  8. HDU 5794 A Simple Chess(杨辉三角+容斥原理+Lucas定理)
  9. linux下kill某个应用
  10. 通配符、正则表达式、python去重