1

I try to build project but this error occured:

Error:Execution failed for task ':app:transformNativeLibsWithMergeJniLibsForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK lib/x86/libjniopenblas.so
    File1: C:\Users\1\.gradle\caches\modules-2\files-2.1\org.bytedeco.javacpp-presets\openblas\0.2.19-1.3\2189141b6c83cc8e5b342b04e8f49e22996f72f4\openblas-0.2.19-1.3-android-x86.jar
    File2: D:\Smart House\Sip projects\Camera\tipit\build\intermediates\bundles\default\jni

How to exclude this directory from build D:\Smart House\Sip projects\Camera\tipit\build\intermediates\bundles\default\jni?

Boken
  • 4,825
  • 10
  • 32
  • 42
Evgeniy Rechkov
  • 465
  • 4
  • 15
  • Possible duplicate: https://stackoverflow.com/questions/36700213/duplicatefileexception-error-while-building-android-apk – Kuffs Oct 25 '17 at 07:30

1 Answers1

2

You can use pickFirst in packagingOptions to use only one of libjniopenblas.so file:

You need to get the correct package name of libjniopenblas.so from File1 or File2:

android {

    ...

    packagingOptions {

       // This is using the library in File1
       pickFirst 'org.bytedeco.javacpp-presets/openblas/lib/x86/libjniopenblas.so'

       ...
    }

   ...
}

But instead of the above, you can using exclude. First, find the dependency which using the libjniopenblas.so by checking it from the dependency tree with:

./gradlew app:dependencies

Then after you found it, exclude it from the library with:

compile('com.library.name:version') {
  exclude "libjniopenblas.so"
  // or exclude the module of the library
}
ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96