javaandroidgradleandroid-gradle-pluginarm64

Conflicts between pytorch and openCV on android


I added

implementation("org.opencv:opencv:4.9.0")

in my build.gradle.kts file.

I get this error when trying to run my app.

2 files found with path 'lib/arm64-v8a/libc++_shared.so' from inputs:
 - C:\Users\user\.gradle\caches\transforms-3\2616944d5f8a63acb398991752c568fa\transformed\pytorch_android-2.1.0\jni\arm64-v8a\libc++_shared.so
 - C:\Users\user\.gradle\caches\transforms-3\d587fbba94c319dd7d2b2c1ae2fc5156\transformed\opencv-4.9.0\jni\arm64-v8a\libc++_shared.so

Solution

  • I needed to add this in build.gradle.kts

    packaging {
            pickFirst("lib/x86/libc++_shared.so")
            pickFirst("lib/x86_64/libc++_shared.so")
            pickFirst("lib/armeabi-v7a/libc++_shared.so")
            pickFirst("lib/arm64-v8a/libc++_shared.so")
        }