我的Android进阶之旅------>解决:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.

错误描述

今天在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

错误截图如下所示:

错误截图

解决办法

在build.gradle文件中加入下面这段代码

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

这里写图片描述

你可能感兴趣的:(我的Android进阶之旅------>解决:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.)