I have a couple of "fully native" c++ applications (based on the native_activity and android_app infrastructure) that I am trying to add OpenCV capability to. I can get them to compile and link, but when I try to launch them, I get errors in the logcat and an "Unfortunately, NativeActivity has stopped" box on the device (a Nexus 10). The errors are part of the loading/launching process -- I haven't even added any code of my own yet!
Using the OpenCV4Android 2.4.4 beta, I can get tutorials 1 and 2 and the face-detection sample to work. The problem is when I try to add OpenCV libraries to a project that uses native_app_glue. I add the following to my android.mk file, after the include $(CLEAR_VARS) line.
#OPENCV_INSTALL_MODULES:=on
OPENCV_CAMERA_MODULES:=off
#OPENCV_LIB_TYPE:=STATIC # doesn't help, conflicts with png
include c:/ThirdParty/OpenCV/OpenCV-2.4.3.2-android-sdk/sdk/native/jni/OpenCV.mk
LOCAL_C_INCLUDES += OPENCV_LOCAL_C_INCLUDES
(The commented-out lines are things that I also tried at some point.) After listing my local_src_files, I have the following before the include $(BUILD_SHARED_LIBRARY) line.
LOCAL_LDLIBS += -landroid -llog -lOpenSLES -lEGL -lGLESv2
LOCAL_LDLIBS += -ldl # have also tried without this
LOCAL_STATIC_LIBRARIES += android_native_app_glue
LOCAL_STATIC_LIBRARIES += png
I have tried many variations on this approach and have also tried it with OpenCV4Android 2.4.3. I get these errors just by trying to link with OpenCV, without even writing any code of my own!
Typical logcat output:
> 02-26 13:33:23.350:
> D/AndroidRuntime(22440): Shutting down
> VM 02-26 13:33:23.350:
> W/dalvikvm(22440): threadid=1: thread
> exiting with uncaught exception
> (group=0x40b58930) 02-26 13:33:23.350:
> E/AndroidRuntime(22440): FATAL
> EXCEPTION: main 02-26 13:33:23.350:
> E/AndroidRuntime(22440):
> java.lang.RuntimeException: Unable to
> start activity
> ComponentInfo{com.droidblaster/android.app.NativeActivity}:
> java.lang.IllegalArgumentException:
> Unable to load native library:
> /data/app-lib/com.droidblaster-2/libdroidblaster.so
> 02-26 13:33:23.350:
> E/AndroidRuntime(22440): at
> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
> 02-26 13:33:23.350:
> E/AndroidRuntime(22440): at
> android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
What am I missing? How can I get this to work?