我的Android进阶之旅------>解决:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
2024-08-30 04:32:42
错误描写叙述
今天在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
最新文章
- 第二天 ci执行流程
- firefox浏览器不支持复制粘贴(linux)
- mysql 行转列 和 列转行
- HTML5和CSS3基础教程(第8版)-读书笔记(2)
- BZOJ3503: [Cqoi2014]和谐矩阵
- SASS、COMPASS 安装指南
- union的用法
- 搜索Collections元素,用DateFormatSymbols 获得月份
- [HeadFist-HTMLCSS学习笔记][第五章认识媒体]
- html基础标签-1-pre预格式标签
- CentOS 安装Chrome
- 在容器中运行 Jenkins pipeline 任务
- [开源]Dapper Repository 一种实现方式
- C#字符串和数组互转
- 搞明白GOROOT,GOPATH,GOBIN,project目录
- 使用FileZilla连接时超时,无法连接到服务器
- 6-16 单词 uva10129
- Codeforces.911F.Tree Destruction(构造 贪心)
- 20180824 SSRS Line Chart 绘制
- curl java 模拟http请求