Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Duplicate files copied in APK Android - Can it be merged?

In my android project I have included two libraries as JARs into libs folder. And I add them to the build Gradle as below.

dependencies {
    compile files('libs/siddhi-core-4.0.0-M13-SNAPSHOT.jar')
    compile files('libs/siddhi-execution-math-4.0.2-SNAPSHOT.jar')
}

Those two jar files the have a file with the same name ("org.wso2.siddhi.annotation.Extension") but with different content. And both files are important for the project. Since it has same name gradle won't build saying

Duplicate files copied in APK

How can I merge those two files into one single file with the same name? Those two files are text files with a list of Class names. In two files they have two different lists. So I want to merge them into one list in a text file with same name.

enter image description here

like image 858
chamathabeysinghe Avatar asked Jul 13 '17 03:07

chamathabeysinghe


1 Answers

Finally I found the answer. In the app build gradle you can specify to merge the conflicting files.

packagingOptions {         
    merge 'META-INF/annotations/org.wso2.siddhi.annotation.Extension'
}

for details look here https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.PackagingOptions.html

like image 76
chamathabeysinghe Avatar answered Oct 07 '22 13:10

chamathabeysinghe