错误:任务执行失败':Find Me:transformResourcesWithMergeJavaResForDebug'

时间:2016-12-07 08:38:12

标签: java android eclipse android-studio

我的应用有问题! build.gradle同步并且没有错误,但是当我想运行应用程序错误时!这是错误:

  

错误:任务执行失败':查找   我:transformResourcesWithMergeJavaResForDebug”

。      

com.android.build.api.transform.TransformException:   com.android.builder.packaging.DuplicateFileException:重复文件   复制在APK META-INF / LICENSE中     File1:C:\ Users **** \ workspace \ Find Me \ libs \ httpclient-4.5.1.jar

     

File2:C:\ Users **** \ workspace \ Find Me \ libs \ httpclient-cache-4.5.1.jar

     

File3:C:\ Users **** \ workspace \ Find Me \ libs \ httpclient-win-4.5.1.jar

     

File4:C:\ Users **** \ workspace \ Find Me \ libs \ _ httpcore-4.4.3.jar

及其build.gradle:

apply plugin: 'com.android.application'

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile project(':android-support-v7-appcompat')
    compile project(':CircularImageView')
    compile project(':FacebookSDK')
    compile project(':google-play-services_lib')
    compile project(':google-play-services_lib')
    compile project(':FacebookSDK')
    compile project(':android-support-v7-appcompat')
    compile project(':CircularImageView')
}

android {
    compileSdkVersion 23
    buildToolsVersion "25.0.1"

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        // Move the tests to tests/java, tests/res, etc...
        instrumentTest.setRoot('tests')

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
}

谢谢

2 个答案:

答案 0 :(得分:0)

在您的祖父档案中,您有compile project(':google-play-services_lib') compile project(':google-play-services_lib') compile project(':FacebookSDK') compile project(':android-support-v7-appcompat') compile project(':CircularImageView')

删除它们,只使用一次

apply plugin: 'com.android.application'

dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':android-support-v7-appcompat')
compile project(':CircularImageView')
compile project(':FacebookSDK')
compile project(':google-play-services_lib')

}

android {
compileSdkVersion 23
buildToolsVersion "25.0.1"

sourceSets {
    main {
        manifest.srcFile 'AndroidManifest.xml'
        java.srcDirs = ['src']
        resources.srcDirs = ['src']
        aidl.srcDirs = ['src']
        renderscript.srcDirs = ['src']
        res.srcDirs = ['res']
        assets.srcDirs = ['assets']
    }

    // Move the tests to tests/java, tests/res, etc...
    instrumentTest.setRoot('tests')

    // Move the build types to build-types/<type>
    // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
    // This moves them out of them default location under src/<type>/... which would
    // conflict with src/ being used by the main source set.
    // Adding new build types or product flavors should be accompanied
    // by a similar customization.
    debug.setRoot('build-types/debug')
    release.setRoot('build-types/release')
}
}

编辑:在android {}

中添加这些行
packagingOptions {
    exclude 'META-INF/DEPENDENCIES.txt'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/dependencies.txt'
    exclude 'META-INF/LGPL2.1'
}

答案 1 :(得分:0)

正如@VygintasB所说删除重复的依赖项并尝试在模块级build.gradle文件中添加此块,错误说 在APK META-INF / LICENSE中复制的重复文件 所以只需排除这些并尝试

android {
 //.....
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
       }     

   }