尝试集成Opencv时,Xamarin.android中的Java.Lang.UnsatisfiedLinkError exexption

时间:2015-07-02 11:09:32

标签: c# android opencv xamarin

我是Xamarin的新手,我一直在努力将Opencv整合到Xamarin.android中。 我正在学习本教程:https://www.youtube.com/watch?v=pFv_1KeMZVs 每当我运行应用程序时,我总是会收到此错误:

[monodroid] Using override path: /data/data/com.companyname.opencv4android/files/.__override__
[monodroid] Trying to load sgen from: /data/data/com.companyname.opencv4android/files/.__override__/libmonosgen-2.0.so
[monodroid] Trying to load sgen from: /storage/sdcard/Android/data/com.companyname.opencv4android/files/.__override__/libmonosgen-2.0.so
[monodroid] Trying to load sgen from: /data/app-lib/com.companyname.opencv4android-1/libmonosgen-2.0.so
[monodroid] Trying to load sgen from: /data/data/com.companyname.opencv4android/files/.__override__/links/libmonosgen-2.0.so
[monodroid-debug] Trying to initialize the debugger with options: --debugger-agent=transport=dt_socket,loglevel=0,address=10.0.2.2:61875,embedding=1
[Mono] Image addref mscorlib[0xb93a1a00] -> mscorlib.dll[0xb93af310]: 1
[Mono] AOT module 'mscorlib.dll.so' not found: dlopen failed: library "/data/app-lib/com.companyname.opencv4android-1/libaot-mscorlib.dll.so" not found
[Mono] AOT module '/Users/builder/data/lanes/monodroid-mavericks-monodroid-5.1-series/d419c934/source/monodroid/builds/install/mono-x86/lib/mono/aot-cache/x86/mscorlib.dll.so' not found: dlopen failed: library "/data/app-lib/com.companyname.opencv4android-1/libaot-mscorlib.dll.so" not found
[Mono] Assembly mscorlib[0xb93a1a00] added to domain RootDomain, ref_count=1
[Mono] Assembly Loader probing location: '/data/data/com.companyname.opencv4android/files/.__override__/Opencv4Android.dll'.
[Mono] Image addref Opencv4Android[0xb93e8250] -> /data/data/com.companyname.opencv4android/files/.__override__/Opencv4Android.dll[0xb93e7680]: 2
[Mono] Assembly Opencv4Android[0xb93e8250] added to domain RootDomain, ref_count=1
[Mono] AOT module '/data/data/com.companyname.opencv4android/files/.__override__/Opencv4Android.dll.so' not found: dlopen failed: library "/data/app-lib/com.companyname.opencv4android-1/libaot-Opencv4Android.dll.so" not found
[Mono] AOT module '/Users/builder/data/lanes/monodroid-mavericks-monodroid-5.1-series/d419c934/source/monodroid/builds/install/mono-x86/lib/mono/aot-cache/x86/Opencv4Android.dll.so' not found: dlopen failed: library "/data/app-lib/com.companyname.opencv4android-1/libaot-Opencv4Android.dll.so" not found
[Mono] Assembly Loader loaded assembly from location: '/data/data/com.companyname.opencv4android/files/.__override__/Opencv4Android.dll'.
[Mono] Config attempting to parse: '/data/data/com.companyname.opencv4android/files/.__override__/Opencv4Android.dll.config'.
[Mono] Config attempting to parse: '/Users/builder/data/lanes/monodroid-mavericks-monodroid-5.1-series/d419c934/source/monodroid/builds/install/mono-x86/etc/mono/assemblies/Opencv4Android/Opencv4Android.config'.
[Mono] Assembly Loader probing location: '/data/data/com.companyname.opencv4android/files/.__override__/OpencvBinding.dll'.
[Mono] Image addref OpencvBinding[0xb93e9190] -> /data/data/com.companyname.opencv4android/files/.__override__/OpencvBinding.dll[0xb93e8530]: 2
[Mono] Assembly OpencvBinding[0xb93e9190] added to domain RootDomain, ref_count=1
[Mono] AOT module '/data/data/com.companyname.opencv4android/files/.__override__/OpencvBinding.dll.so' not found: dlopen failed: library "/data/app-lib/com.companyname.opencv4android-1/libaot-OpencvBinding.dll.so" not found
[Mono] AOT module '/Users/builder/data/lanes/monodroid-mavericks-monodroid-5.1-series/d419c934/source/monodroid/builds/install/mono-x86/lib/mono/aot-cache/x86/OpencvBinding.dll.so' not found: dlopen failed: library "/data/app-lib/com.companyname.opencv4android-1/libaot-OpencvBinding.dll.so" not found
[Mono] Assembly Loader loaded assembly from location: '/data/data/com.companyname.opencv4android/files/.__override__/OpencvBinding.dll'.
[Mono] Config attempting to parse: '/data/data/com.companyname.opencv4android/files/.__override__/OpencvBinding.dll.config'.
[Mono] Config attempting to parse: '/Users/builder/data/lanes/monodroid-mavericks-monodroid-5.1-series/d419c934/source/monodroid/builds/install/mono-x86/etc/mono/assemblies/OpencvBinding/OpencvBinding.config'.
[monodroid-gc] GREF GC Threshold: 1800
[Mono] Image addref Mono.Android[0xb93ea6b0] -> Mono.Android.dll[0xb93e9b10]: 1
[Mono] Assembly Mono.Android[0xb93ea6b0] added to domain RootDomain, ref_count=1
[Mono] AOT module 'Mono.Android.dll.so' not found: dlopen failed: library "/data/app-lib/com.companyname.opencv4android-1/libaot-Mono.Android.dll.so" not found
[Mono] AOT module '/Users/builder/data/lanes/monodroid-mavericks-monodroid-5.1-series/d419c934/source/monodroid/builds/install/mono-x86/lib/mono/aot-cache/x86/Mono.Android.dll.so' not found: dlopen failed: library "/data/app-lib/com.companyname.opencv4android-1/libaot-Mono.Android.dll.so" not found
[Mono] Assembly Ref addref Mono.Android[0xb93ea6b0] -> mscorlib[0xb93a1a00]: 2
[Mono] DllImport attempting to load: '__Internal'.
[Mono] DllImport loaded library '(null)'.
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for '_monodroid_lref_log_new'.
[Mono] Probing '_monodroid_lref_log_new'.
[Mono] Found as '_monodroid_lref_log_new'.
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for '_monodroid_lref_log_delete'.
[Mono] Probing '_monodroid_lref_log_delete'.
[Mono] Found as '_monodroid_lref_log_delete'.
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for '_monodroid_gref_log_new'.
[Mono] Probing '_monodroid_gref_log_new'.
[Mono] Found as '_monodroid_gref_log_new'.
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for '_monodroid_get_identity_hash_code'.
[Mono] Probing '_monodroid_get_identity_hash_code'.
[Mono] Found as '_monodroid_get_identity_hash_code'.
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for '_monodroid_gref_log'.
[Mono] Probing '_monodroid_gref_log'.
[Mono] Found as '_monodroid_gref_log'.
[Mono] Image addref System.Core[0xb94b0900] -> System.Core.dll[0xb94b95e0]: 1
[Mono] Assembly System.Core[0xb94b0900] added to domain RootDomain, ref_count=1
[Mono] AOT module 'System.Core.dll.so' not found: dlopen failed: library "/data/app-lib/com.companyname.opencv4android-1/libaot-System.Core.dll.so" not found
[Mono] AOT module '/Users/builder/data/lanes/monodroid-mavericks-monodroid-5.1-series/d419c934/source/monodroid/builds/install/mono-x86/lib/mono/aot-cache/x86/System.Core.dll.so' not found: dlopen failed: library "/data/app-lib/com.companyname.opencv4android-1/libaot-System.Core.dll.so" not found
[Mono] Assembly Ref addref Mono.Android[0xb93ea6b0] -> System.Core[0xb94b0900]: 2
[Mono] Assembly Ref addref System.Core[0xb94b0900] -> mscorlib[0xb93a1a00]: 3
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for '_monodroid_gref_log_delete'.
[Mono] Probing '_monodroid_gref_log_delete'.
[Mono] Found as '_monodroid_gref_log_delete'.
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for '_monodroid_gc_wait_for_bridge_processing'.
[Mono] Probing '_monodroid_gc_wait_for_bridge_processing'.
[Mono] Found as '_monodroid_gc_wait_for_bridge_processing'.
[Mono] Assembly Ref addref OpencvBinding[0xb93e9190] -> mscorlib[0xb93a1a00]: 4
[Mono] Assembly Ref addref OpencvBinding[0xb93e9190] -> Mono.Android[0xb93ea6b0]: 2
[monodroid] Xamarin/Android Trial Mode Active
[dalvikvm-heap] Grow heap (frag case) to 3.751MB for 995292-byte allocation
[gralloc_goldfish] Emulator without GPU emulation detected.
[Mono] Assembly Ref addref Opencv4Android[0xb93e8250] -> Mono.Android[0xb93ea6b0]: 3
Loaded assembly: MonoDroidConstructors [External]
[Mono] Assembly Ref addref Opencv4Android[0xb93e8250] -> mscorlib[0xb93a1a00]: 5
[Mono] Assembly Ref addref Opencv4Android[0xb93e8250] -> OpencvBinding[0xb93e9190]: 2
[OpenCV] Trying to get library list
[OpenCV] OpenCV error: Cannot load info library for OpenCV
[OpenCV] Library list: ""
[OpenCV] First attempt to load libs
[OpenCV] Trying to init OpenCV libs
[OpenCV] Trying to load library opencv_java
[OpenCV] Cannot load library "opencv_java"
[System.err] java.lang.UnsatisfiedLinkError: Couldn't load opencv_java from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.companyname.opencv4android-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.companyname.opencv4android-1, /system/lib]]]: findLibrary returned null
[System.err]    at java.lang.Runtime.loadLibrary(Runtime.java:358)
[System.err]    at java.lang.System.loadLibrary(System.java:526)
[System.err]    at org.opencv.android.StaticHelper.loadLibrary(StaticHelper.java:49)
[System.err]    at org.opencv.android.StaticHelper.initOpenCVLibs(StaticHelper.java:80)
[System.err]    at org.opencv.android.StaticHelper.initOpenCV(StaticHelper.java:28)
[System.err]    at org.opencv.android.OpenCVLoader.initDebug(OpenCVLoader.java:26)
[System.err]    at mono.android.TypeManager.n_activate(Native Method)
[System.err]    at mono.android.TypeManager.Activate(TypeManager.java:7)
[System.err]    at md571660babd1e4a0eddf8cf854d39530fa.MainActivity.<init>(MainActivity.java:22)
[System.err]    at java.lang.Class.newInstanceImpl(Native Method)
[System.err]    at java.lang.Class.newInstance(Class.java:1208)
[System.err]    at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
[System.err]    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2101)
[System.err]    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
[System.err]    at android.app.ActivityThread.access$800(ActivityThread.java:135)
[System.err]    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
[System.err]    at android.os.Handler.dispatchMessage(Handler.java:102)
[System.err]    at android.os.Looper.loop(Looper.java:136)
[System.err]    at android.app.ActivityThread.main(ActivityThread.java:5001)
[System.err]    at java.lang.reflect.Method.invokeNative(Native Method)
[System.err]    at java.lang.reflect.Method.invoke(Method.java:515)
[System.err]    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
[System.err]    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
[System.err]    at dalvik.system.NativeStart.main(Native Method)
[OpenCV] First attempt to load libs fails
[Mono] DllImport attempting to load: '/system/lib/liblog.so'.
[Mono] DllImport loaded library '/system/lib/liblog.so'.
[Mono] DllImport searching in: '/system/lib/liblog.so' ('/system/lib/liblog.so').
[Mono] Searching for '__android_log_print'.
[Mono] Probing '__android_log_print'.
[Mono] Found as '__android_log_print'.
Init OpenCv failed
[Mono] DllImport attempting to load: '/system/lib/liblog.so'.
[Mono] DllImport loaded library '/system/lib/liblog.so'.
[Mono] DllImport searching in: '/system/lib/liblog.so' ('/system/lib/liblog.so').
[Mono] Searching for '__android_log_print'.
[Mono] Probing '__android_log_print'.
[Mono] Found as '__android_log_print'.
[MonoDroid] UNHANDLED EXCEPTION:
[MonoDroid] Java.Lang.UnsatisfiedLinkError: Exception of type 'Java.Lang.UnsatisfiedLinkError' was thrown.
[MonoDroid] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <IL 0x00011, 0x0004b>
[MonoDroid] at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (intptr,intptr,intptr,Android.Runtime.JValue*) [0x00084] in /Users/builder/data/lanes/monodroid-mavericks-monodroid-5.1-series/d419c934/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:1029
[MonoDroid] at Android.Runtime.JNIEnv.FinishCreateInstance (intptr,intptr,intptr,Android.Runtime.JValue*) [0x0000b] in /Users/builder/data/lanes/monodroid-mavericks-monodroid-5.1-series/d419c934/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.cs:306
[MonoDroid] at Android.Runtime.JNIEnv.FinishCreateInstance (intptr,intptr,intptr,Android.Runtime.JValue[]) [0x0001d] in /Users/builder/data/lanes/monodroid-mavericks-monodroid-5.1-series/d419c934/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.cs:312
[MonoDroid] at Org.Opencv.Core.Mat..ctor () [0x000cb] in c:\Users\SONY\Documents\Projects\Opencv4Android\OpencvBinding\obj\Debug\generated\src\Org.Opencv.Core.Mat.cs:71
[MonoDroid] at Opencv4Android.MainActivity.SetImage () [0x0002a] in c:\Users\SONY\Documents\Projects\Opencv4Android\Opencv4Android\MainActivity.cs:55
[MonoDroid] at Opencv4Android.MainActivity.<OnCreate>b__0 (object,System.EventArgs) [0x00001] in c:\Users\SONY\Documents\Projects\Opencv4Android\Opencv4Android\MainActivity.cs:43
[MonoDroid] at Android.Views.View/IOnClickListenerImplementor.OnClick (Android.Views.View) [0x0000d] in /Users/builder/data/lanes/monodroid-mavericks-monodroid-5.1-series/d419c934/source/monodroid/src/Mono.Android/platforms/android-21/src/generated/Android.Views.View.cs:1923
[MonoDroid] at Android.Views.View/IOnClickListenerInvoker.n_OnClick_Landroid_view_View_ (intptr,intptr,intptr) [0x00011] in /Users/builder/data/lanes/monodroid-mavericks-monodroid-5.1-series/d419c934/source/monodroid/src/Mono.Android/platforms/android-21/src/generated/Android.Views.View.cs:1888
[MonoDroid] at (wrapper dynamic-method) object.b0468be7-dc67-4c6f-ad07-525e21dd1f88 (intptr,intptr,intptr) <IL 0x00017, 0x00027>
[MonoDroid]   --- End of managed exception stack trace ---
[MonoDroid] java.lang.UnsatisfiedLinkError: Native method not found: org.opencv.core.Mat.n_Mat:()J
[MonoDroid]     at org.opencv.core.Mat.n_Mat(Native Method)
[MonoDroid]     at org.opencv.core.Mat.<init>(Mat.java:441)
[MonoDroid]     at mono.android.view.View_OnClickListenerImplementor.n_onClick(Native Method)
[MonoDroid]     at mono.android.view.View_OnClickListenerImplementor.onClick(View_OnClickListenerImplementor.java:29)
[MonoDroid]     at android.view.View.performClick(View.java:4438)
[MonoDroid]     at android.view.View$PerformClick.run(View.java:18422)
[MonoDroid]     at android.os.Handler.handleCallback(Handler.java:733)
[MonoDroid]     at android.os.Handler.dispatchMessage(Handler.java:95)
[MonoDroid]     at android.os.Looper.loop(Looper.java:136)
[MonoDroid]     at android.app.ActivityThread.main(ActivityThread.java:5001)
[MonoDroid]     at java.lang.reflect.Method.invokeNative(Native Method)
[MonoDroid]     at java.lang.reflect.Method.invoke(Method.java:515)
[MonoDroid]     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
[MonoDroid]     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
[MonoDroid]     at dalvik.system.NativeStart.main(Native Method)
[AndroidRuntime] Shutting down VM

我不知道问题是什么!我环顾四周,尝试了一些我找到的解决方案,但没有解决我的问题。 这是我的MainActivity:

[Activity (Label = "Opencv4Android", MainLauncher = true, Icon = "@drawable/icon")]
    public class MainActivity : Activity
    {
        public MainActivity()
        {
            if (!OpenCVLoader.InitDebug ())
                Console.WriteLine ("Init OpenCv failed");
        }
        protected override void OnCreate (Bundle bundle)
        {
            base.OnCreate (bundle);

            // Set our view from the "main" layout resource
            SetContentView (Resource.Layout.Main);
            // Get our button from the layout resource,
            // and attach an event to it
            Button button = FindViewById<Button> (Resource.Id.myButton);

            button.Click += delegate {
                //button.Text = string.Format ("{0} clicks!", count++);
                SetImage ();
            };
        }
        void SetImage()
        {
            ImageView iView = FindViewById<ImageView> (Resource.Id.imageView1);
            using (Bitmap img = BitmapFactory.DecodeResource(Resources, Resource.Drawable.Icon))
            {
                if (img != null ) {  //&& OpenCVLoader.InitDebug ()
                    Mat m = new Mat ();
                    Mat grayM = new Mat ();
                    Utils.BitmapToMat(img, m);
                    Imgproc.CvtColor(m, grayM, Imgproc.ColorRgb2gray);
                    Imgproc.CvtColor(grayM, m, Imgproc.ColorGray2bgr);

                    using(Bitmap ba = Bitmap.CreateBitmap(m.Cols(), m.Rows(), Bitmap.Config.Argb8888))
                        {
                                Utils.MatToBitmap(m,ba);
                                iView.SetImageBitmap(ba);
                        }
                    m.Release();
                    grayM.Release();
                }
            }
        }
    }

请有人帮助我吗?

0 个答案:

没有答案