解决:Execution failed for task ':a

2017-11-01  本文已影响0人  秋sunshine

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
错误图像:

Paste_Image.png

解决办法:
看起来是因为多个 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/article/details/50538658

上一篇下一篇

猜你喜欢

热点阅读