Ask Your Question
0

Can not run OpenCV samples with native C++ code

asked 2014-07-26 21:12:50 -0600

Ryma gravatar image

updated 2014-07-27 00:33:53 -0600

berak gravatar image

Hello,

I'm a newbie in Android developing and it's the first time I use OpenCV. Following OpenCV guide, I managed to run 6 of the 9 applications. The remaining 3 are the one with native C++ code: "Face_detection", "Native_activity" and "mixed_processing". I added the NDK path, at first I added a environment variable NDKROOT, but finally I put the full path.

image description

The Android target is 4.4w (API20)

When I run the application, the message written in the console was:

02:43:08 * Auto Build of configuration Default for project OpenCV Sample - native-activity * "C:\Works\android-ndk-r9d\ndk-build.cmd" Android NDK: WARNING:jni/Android.mk:native_activity: non-system libraries in linker flags: -lopencv_java
Android NDK: This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES
Android NDK: or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the
Android NDK: current module
[armeabi-v7a] Gdbserver : [arm-linux-androideabi-4.6] libs/armeabi-v7a/gdbserver [armeabi-v7a] Gdbsetup : libs/armeabi-v7a/gdb.setup [armeabi-v7a] Install : libnative_activity.so => libs/armeabi-v7a/libnative_activity.so

And those are the errors in the LogCat:

07-27 02:43:18.497: E/dalvikvm(2439): dlopen("/data/app-lib/org.opencv.samples.NativeActivity-2/libnative_activity.so") failed: Cannot load library: load_library(linker.cpp:761): not a valid ELF executable: /data/app-lib/org.opencv.samples.NativeActivity-2/libnative_activity.so 07-27 02:43:18.497: D/AndroidRuntime(2439): Shutting down VM 07-27 02:43:18.497: W/dalvikvm(2439): threadid=1: thread exiting with uncaught exception (group=0xa6186908) 07-27 02:43:18.497: E/AndroidRuntime(2439): FATAL EXCEPTION: main 07-27 02:43:18.497: E/AndroidRuntime(2439): java.lang.UnsatisfiedLinkError: Cannot load library: load_library(linker.cpp:761): not a valid ELF executable: /data/app-lib/org.opencv.samples.NativeActivity-2/libnative_activity.so 07-27 02:43:18.497: E/AndroidRuntime(2439): at java.lang.Runtime.loadLibrary(Runtime.java:371) 07-27 02:43:18.497: E/AndroidRuntime(2439): at java.lang.System.loadLibrary(System.java:535) 07-27 02:43:18.497: E/AndroidRuntime(2439): at org.opencv.samples.NativeActivity.CvNativeActivity$1.onManagerConnected(CvNativeActivity.java:21) 07-27 02:43:18.497: E/AndroidRuntime(2439): at org.opencv.android.AsyncServiceHelper$1.onServiceConnected(AsyncServiceHelper.java:318) 07-27 02:43:18.497: E/AndroidRuntime(2439): at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1101) 07-27 02:43:18.497: E/AndroidRuntime(2439): at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1118) 07-27 02:43:18.497: E/AndroidRuntime(2439): at android.os.Handler.handleCallback(Handler.java:725) 07-27 02:43:18.497: E/AndroidRuntime(2439): at android.os.Handler.dispatchMessage(Handler.java:92) 07-27 02:43:18.497: E/AndroidRuntime(2439): at android.os.Looper.loop(Looper.java:137) 07-27 02:43:18.497: E/AndroidRuntime(2439): at android.app.ActivityThread.main(ActivityThread.java:5041) 07-27 02:43:18.497: E/AndroidRuntime(2439): at java.lang.reflect.Method.invokeNative(Native Method) 07-27 02:43:18.497: E/AndroidRuntime(2439): at java.lang.reflect.Method.invoke(Method.java:511) 07-27 02:43:18.497: E/AndroidRuntime(2439): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 07-27 ...

(more)
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2014-07-27 08:43:42 -0600

FLY gravatar image

updated 2014-07-27 08:46:11 -0600

The below link work for me , follow the link step by step and read it carefully

Opencv with android

Also check point 10 from link in your configuration

edit flag offensive delete link more

Comments

Thanks for answering, that was very nice of you. I think that the probleme is due to the lack of NDK plugins. When I add the link "https://dl-ssl.google.com/android/eclipse/" to install NDK plugins, It does not show up.

Ryma gravatar imageRyma ( 2014-07-29 14:10:50 -0600 )edit

Question Tools

Stats

Asked: 2014-07-26 21:12:50 -0600

Seen: 1,275 times

Last updated: Jul 27 '14