Duplicate file error at build time

After installing a plugin, I’m getting the following error:

Execution failed for task ‘:transformResourcesWithMergeJavaResForDebug’.

com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/DEPENDENCIES File1: C:\Users\Vinicius\Desktop\webapps\paypadapp\platforms\android\libs\httpcore-4.3.2.jar File2: C:\Users\Vinicius\Desktop\webapps\paypadapp\platforms\android\libs\httpclient-4.3.3.jar File3: C:\Users\Vinicius\Desktop\webapps\paypadapp\platforms\android\libs\httpmime-4.3.3.jar

When doing a search, I found the following solution
Add this in android manifest:

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

But where do I add that in ionic / cordova?

Anyone have any idea how I can fix it?

If you think it will solve the issue, then You can add it in your build.gradle

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

Thanks for reply. Could you tell me where the build.gradle is for me to test? I tried searching the project and returned nothing

It should be under /platforms/android

Thanks man. I will try this

Unfortunately it did not work :frowning:

  • What went wrong:
    Execution failed for task ‘:transformResourcesWithMergeJavaResForDebug’.

com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/DEPENDENCIES
File1: C:\Users\Vinicius\Desktop\webapps\paypadapp\platforms\android\libs\httpcore-4.3.2.jar
File2: C:\Users\Vinicius\Desktop\webapps\paypadapp\platforms\android\libs\httpclient-4.3.3.jar
File3: C:\Users\Vinicius\Desktop\webapps\paypadapp\platforms\android\libs\httpmime-4.3.3.jar

Whch plugin and How did you install the plugin in the first place. Can you remove your plugin and try to build it

plugin: GitHub - StephenForte/sendgrid-cordova-plugin

I installed it like this:

cordova plugin add https://github.com/StephenForte/sendgrid-cordova-plugin --variable API_USER="myusername" --variable API_KEY=keykeykey

I installed this plugin last

I created an ionic project from scratch and installed the plugin, the same error occurs

Seems like the plugin is not compatible with your cordova android version.
You have to contact Telerik support or if it just for sending mails, you can use MailGun
https://documentation.mailgun.com/api-sending.html#sending

1 Like

Thank you, that explains a lot.
I will try MailGun