错误:任务“:app:transformResourcesWithMergeJavaResForDeb

Error:Execution failed for task #39;:app:transformResourcesWithMergeJavaResForDebug#39;(错误:任务“:app:transformResourcesWithMergeJavaResForDebug执行失败)

本文介绍了错误:任务“:app:transformResourcesWithMergeJavaResForDebug"执行失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我在尝试运行我的项目时不断收到 gradle build 错误.我已经搜索了其他解决方案,有人说添加:

So I'm continuously receiving a gradle build error upon trying to run my project. I have searched for other solutions and some say that adding:

packagingOptions {
    exclude 'META-INF/NOTICE'
}

到我的应用程序的 gradle.build 将解决问题,但是,它没有.这是我的应用的 gradle.build 目前的样子.

to my app's gradle.build would fix the issue, however, it doesn't. Here is what my app's gradle.build currently looks like.

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.google.android.gms:play-services:8.3.0'
    compile 'com.google.android.gms:play-services-ads:8.3.0'
    compile 'com.google.android.gms:play-services-identity:8.3.0'
    compile 'com.firebase:firebase-client-android:2.3.1'
}

android {
    compileSdkVersion 23
    buildToolsVersion '23.0.1'
    useLibrary 'org.apache.http.legacy'

    defaultConfig {
        applicationId "com.example.j.airportmeet"
        minSdkVersion 18
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }

    packagingOptions {
        exclude 'META-INF/NOTICE'
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

编辑

完整的错误是这样的:

Edit

The full error is this:

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/LICENSE
    File1: .gradlecachesmodules-2files-2.1com.fasterxml.jackson.corejackson-databind2.2.23c8f6018eaa72d43b261181e801e6f8676c16ef6jackson-databind-2.2.2.jar
    File2: .gradlecachesmodules-2files-2.1com.fasterxml.jackson.corejackson-core2.2.2d20be6a5ddd6f8cfd36ebf6dea329873a1c41f1bjackson-core-2.2.2.jar
    File3: .gradlecachesmodules-2files-2.1com.fasterxml.jackson.corejackson-annotations2.2.2285cb9c666f0f0f3dd8a1be04e1f457eb7b15113jackson-annotations-2.2.2.jar

推荐答案

正如错误消息所示,您没有排除存在于多个依赖项中的 META-INF/LICENSE 文件

As the error message suggests you are not excluding the META-INF/LICENSE file which exists in more than one of your dependencies

com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: 在 APK META-INF/LICENSE 中复制的文件重复

com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/LICENSE

packagingOptions {
    exclude 'META-INF/NOTICE' // will not include NOTICE file
    exclude 'META-INF/LICENSE' // will not include LICENSE file
    // as noted by @Vishnuvathsan you may also need to include
    // variations on the file name. It depends on your dependencies.
    // Some other common variations on notice and license file names
    exclude 'META-INF/notice'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/license'
    exclude 'META-INF/license.txt'
}

这篇关于错误:任务“:app:transformResourcesWithMergeJavaResForDebug"执行失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:错误:任务“:app:transformResourcesWithMergeJavaResForDeb

基础教程推荐