0

I have studied all the similar cases within stackoverflow, but the proposed solutions seem to be quite specific, depending totally on the combination of dependencies declared in the gradle file.

I manage to build successfully, but when I try to run the App, I get:

Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.

com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK com/fasterxml/jackson/core/json/VERSION.txt

File1: /media/barmistias/9668C07068C050A3/AndroidApps/LMMovies/app/libs/jackson-core-2.1.3.jar

File2: /home/barmistias/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-core/2.1.3/f6c3aed1cdfa21b5c1737c915186ea93a95a58bd/jackson-core-2.1.3.jar

And my Gradle file is:

apply plugin: 'com.android.application'

android {
compileSdkVersion 27
buildToolsVersion '27.0.0'
defaultConfig {
    applicationId "com.languagematerial.lmmovies"
    minSdkVersion 21
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    multiDexEnabled true
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
productFlavors {
}
}

repositories{
   mavenCentral()
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:27.0.0'
compile 'com.android.support:recyclerview-v7:27.0.0'
compile 'com.android.support:support-media-compat:27.0.0'
compile 'com.android.support:support-v4:27.0.0'
android {
    configurations.all {
        resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
    }
}
compile 'com.android.support:multidex:1.0.0'

compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
compile 'org.apmem.tools:layouts:1.10@aar'
compile 'com.github.wseemann:FFmpegMediaMetadataRetriever:1.0.14'
compile 'com.nononsenseapps:filepicker:4.1.0'
compile 'org.apache.commons:commons-io:1.3.2'
testCompile 'junit:junit:4.12'
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile 'pub.devrel:easypermissions:0.3.0'
compile('com.google.api-client:google-api-client-android:1.23.0') {
    exclude group: 'org.apache.httpcomponents'
}
compile('com.google.apis:google-api-services-youtube:v3-rev186-1.23.0') {
    exclude group: 'org.apache.httpcomponents'
}
compile 'com.squareup.picasso:picasso:2.5.2'
}

The most used suggestion to solve the issue is:

packagingOptions{
    exclude 'META-INF/VERSION' // or: pickfirst...?
    exclude 'META-INF/VERSION.txt'
    exclude 'META-INF/version.txt'
}

In my case, the error persists, and worse, a new error appears when the compiler cannot find a necessary file. One question: wouldn't it be better to use pickfirst type instructions instead of exclude ones? So, any ideas? Thanks.

Carlos Botero
  • 319
  • 3
  • 11
  • Possible duplicate of [com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/maven/com.fasterxml.jackson.core/jackson-databind/pom.xml](https://stackoverflow.com/questions/37428636/com-android-builder-packaging-duplicatefileexception-duplicate-files-copied-in) – Nawrez Nov 06 '17 at 16:30
  • HadjKhelil Nawrez: You are right. It was indeed an analogous case because I followed its solution procedure and it worked: Apart from adding the right packagingOptions, I had to remove: compile fileTree(dir: 'libs', include: '*.jar'). – Carlos Botero Nov 06 '17 at 17:18

1 Answers1

0

Instead of this

packagingOptions {

        exclude 'META-INF/VERSION' // or: pickfirst...?
        exclude 'META-INF/VERSION.txt'
        exclude 'META-INF/version.txt'

    }

try this

 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'

   }
Nawrez
  • 3,314
  • 8
  • 28
  • 42
  • Thanks for your contribution. I implemented the suggested piece of code. Not working. The same error remains. Any other suggestion? – Carlos Botero Nov 06 '17 at 17:12