Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'

前端 未结 3 694
感动是毒
感动是毒 2020-11-27 04:55

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:

packagingOpt         


        
相关标签:
3条回答
  • 2020-11-27 05:05

    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: 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'
    }
    
    0 讨论(0)
  • 2020-11-27 05:08

    I faced the same issue. In my case,by adding the below code to the build.gradle(Module: app), inside the android{...} tag, solved the issue

    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'
    }
    
    0 讨论(0)
  • 2020-11-27 05:14

    In my case, I had two references to the same library .jar, only deleted one of them and voilà, it is compiling now, it is working.

    enter image description here

    0 讨论(0)
提交回复
热议问题