Ich habe OpenCV-Code (C++), die ich in Android verwenden möchte. Um dies zu tun, muss ich Android NDK verwenden. Ich lud OpenCV package for Android development (ver. 2.4.0) herunter und tat alle Schritte von diesem Handbuch. Einfache Beispiele (nur Java API) laufen ohne Probleme. Beispiel # 3 (Lernprogramm 3 (für Fortgeschrittene) - Native OpenCV hinzufügen) baut von ndk-builder korrekt auf. Bekam aber immer Ausnahme, wenn ich versuche, es zu laufen/debug auf dem Gerät von Eclipse:Kann native Bibliothek in OpenCV Android Probe nicht verbinden
Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lorg/opencv/samples/tutorial3/Sample3View;
In dieser Zeile:
System.loadLibrary("native_sample");
hier voll logcat log:
05-31 23:41:45.976: W/ActivityThread(9708): Application org.opencv.samples.tutorial3 is waiting for the debugger on port 8100...
05-31 23:41:45.983: I/System.out(9708): Sending WAIT chunk
05-31 23:41:45.983: I/dalvikvm(9708): Debugger is active
05-31 23:41:46.179: I/System.out(9708): Debugger has connected
05-31 23:41:46.179: I/System.out(9708): waiting for debugger to settle...
05-31 23:41:46.382: I/System.out(9708): waiting for debugger to settle...
05-31 23:41:46.585: I/System.out(9708): waiting for debugger to settle...
05-31 23:41:46.788: I/System.out(9708): waiting for debugger to settle...
05-31 23:41:46.983: I/System.out(9708): waiting for debugger to settle...
05-31 23:41:47.186: I/System.out(9708): waiting for debugger to settle...
05-31 23:41:47.389: I/System.out(9708): waiting for debugger to settle...
05-31 23:41:47.585: I/System.out(9708): waiting for debugger to settle...
05-31 23:41:47.788: I/System.out(9708): debugger has settled (1463)
05-31 23:41:47.819: D/szipinf(9708): Initializing inflate state
05-31 23:41:47.866: I/Sample::Activity(9708): Instantiated new class org.opencv.samples.tutorial3.Sample3Native
05-31 23:41:48.909: D/dalvikvm(9708): threadid=1: still suspended after undo (sc=1 dc=1)
05-31 23:41:51.770: I/Sample::Activity(9708): onCreate
05-31 23:41:59.283: W/dalvikvm(9708): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lorg/opencv/samples/tutorial3/Sample3View;
05-31 23:42:01.965: D/AndroidRuntime(9708): Shutting down VM
05-31 23:42:01.965: W/dalvikvm(9708): threadid=1: thread exiting with uncaught exception (group=0x40015560)
05-31 23:42:01.999: E/AndroidRuntime(9708): FATAL EXCEPTION: main
05-31 23:42:01.999: E/AndroidRuntime(9708): java.lang.ExceptionInInitializerError
05-31 23:42:01.999: E/AndroidRuntime(9708): at org.opencv.samples.tutorial3.Sample3Native.onCreate(Sample3Native.java:21)
05-31 23:42:01.999: E/AndroidRuntime(9708): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-31 23:42:01.999: E/AndroidRuntime(9708): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1722)
05-31 23:42:01.999: E/AndroidRuntime(9708): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
05-31 23:42:01.999: E/AndroidRuntime(9708): at android.app.ActivityThread.access$1500(ActivityThread.java:123)
05-31 23:42:01.999: E/AndroidRuntime(9708): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
05-31 23:42:01.999: E/AndroidRuntime(9708): at android.os.Handler.dispatchMessage(Handler.java:99)
05-31 23:42:01.999: E/AndroidRuntime(9708): at android.os.Looper.loop(Looper.java:130)
05-31 23:42:01.999: E/AndroidRuntime(9708): at android.app.ActivityThread.main(ActivityThread.java:3835)
05-31 23:42:01.999: E/AndroidRuntime(9708): at java.lang.reflect.Method.invokeNative(Native Method)
05-31 23:42:01.999: E/AndroidRuntime(9708): at java.lang.reflect.Method.invoke(Method.java:507)
05-31 23:42:01.999: E/AndroidRuntime(9708): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
05-31 23:42:01.999: E/AndroidRuntime(9708): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
05-31 23:42:01.999: E/AndroidRuntime(9708): at dalvik.system.NativeStart.main(Native Method)
05-31 23:42:01.999: E/AndroidRuntime(9708): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load native_sample: findLibrary returned null
05-31 23:42:01.999: E/AndroidRuntime(9708): at java.lang.Runtime.loadLibrary(Runtime.java:429)
05-31 23:42:01.999: E/AndroidRuntime(9708): at java.lang.System.loadLibrary(System.java:554)
05-31 23:42:01.999: E/AndroidRuntime(9708): at org.opencv.samples.tutorial3.Sample3View.<clinit>(Sample3View.java:48)
05-31 23:42:01.999: E/AndroidRuntime(9708): ... 14 more
I finden Sie Lösungen für das gleiche Problem, aber keiner von ihnen hat mir nicht geholfen:
- Native OpenCV Samples for Android throws UnsatisfiedLinkError
- java.lang.UnsatisfiedLinkError: Couldn't load opencv_java: findLibrary returned null
- Major OpenCV-Android for Windows Installing and Running Issues (keine Antwort)
Auch habe ich es auf verschiedenen Geräten und Android API-Versionen getestet.
Meine Systemkonfiguration:
[email protected]:~$ uname -a
Linux astor-K42Jv 3.2.0-24-generic-pae #39-Ubuntu SMP Mon May 21 18:54:21 UTC 2012 i686 i686 i386 GNU/Linux
Ich habe versucht, für 4 Nächte, dieses Problem zu beheben (es ist meine freie Zeit :)), aber ohne Glück. Ich brauche das wirklich für meine Doktorarbeit, also wird jede Hilfe geschätzt.
Update: ich diese Probe auf Windows 7 getestet (64), aber Ergebnis ist das gleiche.
Es scheint, dass dies OpenCV-Fehler ist.
Update: Build-Log:
[email protected]:/opt/eclipse-android/workspace/OpenCV-2.4.0-samples/tutorial-3-native$ ndk-build
Install : libnative_camera_r2.2.0.so => libs/armeabi-v7a/libnative_camera_r2.2.0.so
Install : libnative_camera_r2.3.3.so => libs/armeabi-v7a/libnative_camera_r2.3.3.so
Install : libnative_camera_r3.0.1.so => libs/armeabi-v7a/libnative_camera_r3.0.1.so
Install : libnative_camera_r4.0.0.so => libs/armeabi-v7a/libnative_camera_r4.0.0.so
Install : libnative_camera_r4.0.3.so => libs/armeabi-v7a/libnative_camera_r4.0.3.so
Install : libnative_sample.so => libs/armeabi-v7a/libnative_sample.so
möglich Duplikat [Nicht-Systembibliotheken in Linker-Flags] (http://stackoverflow.com/questions/24669518/non-system-libraries-in-linker-flags) –