1

After that i added two jar files: compile files('libs/json-simple.jar') compile files('libs/core-renderer-minimal.jar') I get this error message: 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/INDEX.LIST File1: C:\AndroidStudioProjects\test\app\libs\jackson.jar File2: C:\AndroidStudioProjects\test\app\libs\core-renderer-minimal.jar I didn't found solution for this exception.

My build.gradle:

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "26.0.1"
    defaultConfig {
        applicationId "adms.test"
        minSdkVersion 21
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    dexOptions {
        javaMaxHeapSize "4g"
    }

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

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 files('libs/aspose-pdf-17.7-android-via-java.jar')
    compile files('libs/jackson.jar')
    compile files('libs/json-simple.jar')
    compile files('libs/org.apache.commons.io.jar')
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
    compile files('libs/acrobat-1.1.jar')
    compile files('libs/xml-apis-xerces-2.9.1.jar')
    compile files('libs/com.lowagie.text-2.1.7.jar')
    compile files('libs/core-renderer-minimal.jar')
}

I searched in google and found some solutions, for example:

    packagingOptions {
        pickFirst 'META-INF/INDEX.LIST'
        pickFirst 'META-INF/LICENSE'
        pickFirst 'META-INF/io.netty.versions.properties'
    }

packagingOptions {
   pickFirst  'META-INF/license.txt'
}

packagingOptions {
  exclude 'META-INF/maven/com.squareup.okhttp3/okhttp/pom.properties'
  exclude 'META-INF/maven/com.squareup.okio/okio/pom.xml'
  exclude 'META-INF/maven/com.squareup.okhttp3/okhttp/pom.xml'
  exclude 'META-INF/maven/com.squareup.okio/okio/pom.properties'
}

but them not working.

How can i fix this?

Thanks,

Tal

tal
  • 83
  • 1
  • 1
  • 8

1 Answers1

0

Add below code in android tag in build.gradle and rebuild project;

  packagingOptions {
    exclude 'META-INF/NOTICE' // will not include NOTICE file
    exclude 'META-INF/LICENSE' // will not include LICENSE file
    exclude 'META-INF/DEPENDENCIES' // will not include LICENSE file
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
}
Vishal Vaishnav
  • 3,346
  • 3
  • 26
  • 57