I connected two libraries:

commons-net-3.5.jar

commons-io-2.5.jar

When starting the project, the following error occurs :

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/LICENSE.txt File1: C:\Users\user\AndroidStudioProjects\Sender0.4\app\libs\commons-io-2.5.jar File2: C:\Users\user\AndroidStudioProjects\Sender0.4\app\libs\commons-net-3.5.jar 

A little googling found a solution, a code that needs to be written in build.gradle (module: app):

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

but it did not help, and even aggravated the situation, causing an error when building the project.

Code build.gradle (module: app):

 apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion "24.0.1" defaultConfig { applicationId "com.example.user.sender04" minSdkVersion 15 targetSdkVersion 23 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.4.0' compile files('libs/commons-net-3.5.jar') compile files('libs/commons-io-2.5.jar') } packagingOptions { exclude 'META-INF/LICENSE' exclude 'META-INF/LICENSE.txt' exclude 'META-INF/license.txt' exclude 'META-INF/NOTICE' exclude 'META-INF/NOTICE.txt' exclude 'META-INF/notice.txt' } 

    1 answer 1

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

    it should work


    You pasted my piece in the wrong section. It is necessary so:

     apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion "24.0.1" defaultConfig { applicationId "com.example.user.sender04" minSdkVersion 15 targetSdkVersion 23 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } packagingOptions { exclude 'META-INF/LICENSE' exclude 'META-INF/LICENSE.txt' exclude 'META-INF/license.txt' exclude 'META-INF/NOTICE' exclude 'META-INF/NOTICE.txt' exclude 'META-INF/notice.txt' } } dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.4.0' compile files('libs/commons-net-3.5.jar') compile files('libs/commons-io-2.5.jar') } 
    • Unfortunately, this did not help either, the same error, an error when building the project - Engineman
    • @Engineman, 1. show the error, 2. show the build.gradle file - Vladyslav Matviienko
    • Error: (29, 0) Grade DSL method not found: 'packagingOptions ()' Possible causes: Open The Gradle Wrapper Apply Gradle plugin - Error - Engineman
    • file build.gradle added to the description - Engineman
    • @Engineman, updated the answer - Vladyslav Matviienko