Search code examples
androidcordovabuild.gradlecordova-plugins

Duplicate files copied in APK META-INF/LICENSE - Cordova Couchabse-Lite Plugin


When I add the couchbase lite cordova plugin from:

https://github.com/couchbaselabs/Couchbase-Lite-PhoneGap-Plugin

I get this error when building:

Duplicate files copied in APK META-INF/LICENSE
        File 1: C:\JavaScript\Project-Angular\platforms\android\libs\jackson-databind-2.5.0.jar
        File 2: C:\JavaScript\Project-Angular\platforms\android\libs\jackson-databind-2.5.0.jar

You can ignore those files in your build.gradle:
        android {
          packagingOptions {
            exclude 'META-INF/LICENSE'
          }
        }

I know it has something to do with the build.gradle file but I've searched everywhere and all the questions are about Android directly. I don't know how I'm supposed to edit the build.gradle file since its edited.

Removing the plugin fixes the problem


Solution

  • To fix this problem, you must create a file called platforms/android/build-extras.gradle within your project. With that file created, you can paste the following code:

    android {
        packagingOptions {
            exclude 'META-INF/ASL2.0'
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/NOTICE'
        }
    }
    

    The next time you try to build and run your project for Android, you should no longer suffer from that problem.

    Further documentation on Apache Cordova's build-extras.gradle file can be found in the official documentation:

    https://cordova.apache.org/docs/en/5.0.0/guide/platforms/android/tools.html

    Best,