Android builder packaging DuplicateFileException

The com.android.builder.packaging.DuplicateFileException from running an Android app after added some libraries in the dependencies.

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

The fix, add this in the app build gradle file inside the android tag

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }

Search within Codexpedia

Custom Search

Search the entire web

Custom Search