flutter_native_opencv icon indicating copy to clipboard operation
flutter_native_opencv copied to clipboard

Android build on Windows fails

Open RedstoneMedia opened this issue 3 years ago • 2 comments

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 ?

RedstoneMedia avatar Feb 21 '22 18:02 RedstoneMedia

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

srodrigo avatar May 02 '22 14:05 srodrigo

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'
    }
}

andy6804tw avatar Oct 08 '22 13:10 andy6804tw