I have my app building and running just fine, until I try to actually do anything with the native code components. I"m currently trying to get Example 2 running, which draws features on the screen. Here's my code
JNIEXPORT void JNICALL Java_com_tetragramm_opencvandroid_OpenCVAndroid_FindFeatures
(JNIEnv* env, jobject obj, jlong addrGray, jlong addrRgba)
{
Mat& mGr = *(Mat*)addrGray;
Mat& mRgb = *(Mat*)addrRgba;
vector<KeyPoint> v;
Ptr<FeatureDetector> detector = FastFeatureDetector::create(50);
detector->detect(mGr, v);
}
As soon as I add the last line, the app fails on start up. In logcat it leaves an error saying
java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "_ZN3tbb19task_scheduler_init9terminateEv" referenced by "libjni_part.so"...
It appears to be a problem with tbb, but I think I'm loading that just fine. Here are the build.gradle settings I'm using.
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
applicationId "com.tetragramm.opencvandroid"
minSdkVersion 15
targetSdkVersion 19
versionCode 1
versionName "1.0"
ndk {
moduleName "jni_part"
stl = "gnustl_static"
cFlags = "-I${file("F:/libraries/OpenCV/OpenCV-android-sdk/sdk/native/jni/include")} ".toString()
cFlags += " -std=c++11"
ldLibs = ["android", "log", "z"]
}
}
// This actual the app version code. Our given range is [0, 99999]
defaultConfig.versionCode = 123
// 2 dimensions of flavors. API is more important than ABI.
flavorDimensions "abi"
productFlavors {
arm {
flavorDimension "abi"
ndk {
abiFilter "armeabi-v7a"
File curDir = file('./')
curDir = file(curDir.absolutePath)
String libsDir = "F:\\libraries\\OpenCV\\OpenCV-android-sdk\\sdk\\native\\libs\\armeabi-v7a\\" //"-L" +
String libsDir3rdParty = "F:\\libraries\\OpenCV\\OpenCV-android-sdk\\sdk\\native\\3rdparty\\libs\\armeabi-v7a\\" //"-L" +
ldLibs libsDir3rdParty + "liblibtiff.a"
ldLibs.add(libsDir3rdParty + "liblibjpeg.a")
ldLibs.add(libsDir3rdParty + "liblibjasper.a")
ldLibs.add(libsDir3rdParty + "liblibpng.a")
ldLibs.add(libsDir3rdParty + "libIlmImf.a")
ldLibs.add(libsDir3rdParty + "liblibwebp.a")
ldLibs.add(libsDir3rdParty + "libtbb.a")
ldLibs.add(libsDir + "libopencv_calib3d.a")
ldLibs.add(libsDir + "libopencv_core.a")
ldLibs.add(libsDir + "libopencv_features2d.a")
ldLibs.add(libsDir + "libopencv_flann.a")
//ldLibs.add(libsDir + "libopencv_hal.a")
ldLibs.add(libsDir + "libopencv_highgui.a")
ldLibs.add(libsDir + "libopencv_imgcodecs.a")
ldLibs.add(libsDir + "libopencv_imgproc.a")
ldLibs.add(libsDir + "libopencv_java3.so")
ldLibs.add(libsDir + "libopencv_ml.a")
ldLibs.add(libsDir + "libopencv_objdetect.a")
ldLibs.add(libsDir + "libopencv_photo.a")
ldLibs.add(libsDir + "libopencv_shape.a")
ldLibs.add(libsDir + "libopencv_stitching.a")
ldLibs.add(libsDir + "libopencv_superres.a")
ldLibs.add(libsDir + "libopencv_ts.a")
ldLibs.add(libsDir + "libopencv_video.a")
ldLibs.add(libsDir + "libopencv_videoio.a")
ldLibs.add(libsDir + "libopencv_videostab.a")
ldLibs.add("F:\\Users\\Tetragramm\\AppData\\Local\\Android\\sdk\\ndk-bundle\\sources\\cxx-stl\\gnu-libstdc++\\4.9\\libs\\armeabi-v7a\\libgnustl_static.a")
}
versionCode = 1
}
I'm using the latest SDK, and the tablet is fully up to date. I'm afraid I have no idea what's wrong. If there's any more information that will be useful, just let me know.