jeremy-ellis-tech / Xamarin.Android.OpenCV

C# bindings for the OpenCV Android SDK
MIT License
92 stars 44 forks source link

var m = new Mat(); results in Java.Lang.UnsatisfiedLinkError: No implementation found for.. #6

Closed JelleDamen closed 8 years ago

JelleDamen commented 8 years ago

When I try to construct a Mat object, I get the following runtime error:

[MonoDroid] UNHANDLED EXCEPTION:
[MonoDroid] Java.Lang.UnsatisfiedLinkError: No implementation found for long org.opencv.core.Mat.n_Mat() (tried Java_org_opencv_core_Mat_n_1Mat and Java_org_opencv_core_Mat_n_1Mat__)
[MonoDroid]   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/2923/52635947/source/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 
[MonoDroid]   at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualVoidMethod (JniObjectReference instance, JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x000a7] in /Users/builder/data/lanes/3415/ffca580c/source/Java.Interop/src/Java.Interop/Java.Interop/JniEnvironment.g.cs:12083 
[MonoDroid]   at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (IntPtr jobject, IntPtr jclass, IntPtr jmethod, Android.Runtime.JValue* parms) [0x00000] in /Users/builder/data/lanes/3415/ffca580c/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:444 
[MonoDroid]   at Android.Runtime.JNIEnv.FinishCreateInstance (IntPtr instance, IntPtr jclass, IntPtr constructorId, Android.Runtime.JValue* constructorParameters) [0x0000b] in /Users/builder/data/lanes/3415/ffca580c/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.cs:339 
[MonoDroid]   at Android.Runtime.JNIEnv.FinishCreateInstance (IntPtr instance, IntPtr jclass, IntPtr constructorId, Android.Runtime.JValue[] constructorParameters) [0x0001d] in /Users/builder/data/lanes/3415/ffca580c/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.cs:345 
[MonoDroid]   at OpenCV.Core.Mat..ctor () [0x000da] in /Users/jelle/Downloads/Xamarin.Android.OpenCV-develop/src/OpenCV.Binding/obj/Debug/generated/src/OpenCV.Core.Mat.cs:260 
[MonoDroid]   at OpenCV.SDKDemo.CameraPreview.CameraPreviewActivity.OnCreate (Android.OS.Bundle savedInstanceState) [0x0004c] in /Users/jelle/Downloads/Xamarin.Android.OpenCV-develop/src/OpenCV.SDKDemo/CameraPreview/CameraPreviewActivity.cs:32 
[MonoDroid]   at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (IntPtr jnienv, IntPtr native__this, IntPtr native_savedInstanceState) [0x00011] in /Users/builder/data/lanes/3415/ffca580c/source/monodroid/src/Mono.Android/platforms/android-21/src/generated/Android.App.Activity.cs:2297 
[MonoDroid]   at (wrapper dynamic-method) System.Object:e2174557-e2b1-4b98-8d14-acb189855b49 (intptr,intptr,intptr)
[MonoDroid]   --- End of managed exception stack trace ---
[MonoDroid] java.lang.UnsatisfiedLinkError: No implementation found for long org.opencv.core.Mat.n_Mat() (tried Java_org_opencv_core_Mat_n_1Mat and Java_org_opencv_core_Mat_n_1Mat__)
[MonoDroid]     at org.opencv.core.Mat.n_Mat(Native Method)
[MonoDroid]     at org.opencv.core.Mat.<init>(Mat.java:24)
[MonoDroid]     at md56a82326cf3613e78f478cd0b059b3a72.CameraPreviewActivity.n_onCreate(Native Method)
[MonoDroid]     at md56a82326cf3613e78f478cd0b059b3a72.CameraPreviewActivity.onCreate(CameraPreviewActivity.java:39)
[MonoDroid]     at android.app.Activity.performCreate(Activity.java:6237)
[MonoDroid]     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
[MonoDroid]     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
[MonoDroid]     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
[MonoDroid]     at android.app.ActivityThread.-wrap11(ActivityThread.java)
[MonoDroid]     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
[MonoDroid]     at android.os.Handler.dispatchMessage(Handler.java:102)
[MonoDroid]     at android.os.Looper.loop(Looper.java:148)
[MonoDroid]     at android.app.ActivityThread.main(ActivityThread.java:5417)
[MonoDroid]     at java.lang.reflect.Method.invoke(Native Method)
[MonoDroid]     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
[MonoDroid]     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

Is there something missing in the binding project? Any help would be appreciated.

jeremy-ellis-tech commented 8 years ago

The SDKDemo shows Mats being created with the default constructor (example here) which doesn't crash. Are you sure you've initialized the OpenCV libraries properly using OpenCVLoader.InitAsync()?

JelleDamen commented 8 years ago

That was it, thanks!