westracer / flutter_native_opencv

Using OpenCV natively in C++ in a Flutter app with Dart FFI
https://medium.com/flutter-community/integrating-c-library-in-a-flutter-app-using-dart-ffi-38a15e16bc14
MIT License
213 stars 38 forks source link

Android build on Windows fails #13

Open RedstoneMedia opened 2 years ago

RedstoneMedia commented 2 years ago

Running flutter build apk --debug on my Windows 10 system fails with this error :

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':native_opencv:externalNativeBuildDebug'.
> Build command failed.
  Error while executing process D:\Programms\Android\sdk\cmake\3.10.2.4988404\bin\ninja.exe with arguments {-C <project-path>\flutter_native_opencv\native_opencv\android\.cxx\cmake\debug\arme
abi-v7a native_opencv}
  ninja: Entering directory `<project-path>\flutter_native_opencv\native_opencv\android\.cxx\cmake\debug\armeabi-v7a'

  ninja: error: '../../../../src/main/jniLibs/armeabi-v7a/libopencv_java4.so', needed by '<project-path>/build/native_opencv/intermediates/cmake/debug/obj/armeabi-v7a/libnative_opencv.so', mi
ssing and no known rule to make it

Is this a known issue or am I doing something wrong ?

srodrigo commented 2 years ago

Hi @RedstoneMedia - I ran into the same issue. You probably need to follow these steps on the README, to add the sdk https://github.com/westracer/flutter_native_opencv/blob/master/README.md?plain=1#L13-L19

andy6804tw commented 1 year ago

To fix this you have to write this code in native_opencv/android/app/build.gradle file

android {
    packagingOptions {
        pickFirst 'lib/armeabi-v7a/libopencv_java4.so'
        pickFirst 'lib/arm64-v8a/libopencv_java4.so'
        pickFirst 'lib/x86/libopencv_java4.so'
        pickFirst 'lib/x86_64/libopencv_java4.so'
    }
}