Android Gradle Duplicate files copied in APK META-INF/license.txt

Its helps me. Try this code:)

packagingOptions {
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/NOTICE'
}

If the solution in the selected answer does not fix your problem, try adding

    exclude 'META-INF/ASL2.0'

as well. Or basically, identify the name of the duplicate file and exclude it. The addition above fixed the issue for me.


Write below lines in your app level gradle file

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'
    }
}