简体   繁体   中英

Android NDK does not react on change

I am implementing Android camera app where I am processing preview frames in JNI. I have processImage.cpp file where I do all the native processing and it worked until now when I have discovered that if I do any change to the native file, it does not change the behaviour of the app.

Maybe it could be connected to the static linking of OpenCV library that I've added recently and where I load the native library.

package fit.vutbr.faceswap;

// OpenCV static initialization
    static {
        if (!OpenCVLoader.initDebug()) {
            // Handle initialization error
            Log.d(TAG, "OpenCV init error");
        }
        else {
            System.loadLibrary("processImage");
            //System.loadLibrary("detection_based_tracker");
        }
    }

Android.mk

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

# OpenCV
OPENCV_LIB_TYPE:=STATIC
OPENCV_CAMERA_MODULES:=on
OPENCV_INSTALL_MODULES:=on
include C:\Users\Acer\Projects\OpenCV\OpenCV-2.4.6-android-sdk\sdk\native\jni\OpenCV.mk

LOCAL_C_INCLUDE:= C:\Users\Acer\Projects\OpenCV\OpenCV-2.4.6-android-sdk\sdk\native\jni\include
LOCAL_LDLIBS += -llog -ldl
LOCAL_MODULE    := processImage  
LOCAL_SRC_FILES := processImage.cpp 



include $(BUILD_SHARED_LIBRARY)

Application.mk

APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -fexceptions
APP_ABI := armeabi-v7a
APP_MODULES := processImage

Declaration of the native method:

private native int[] kalmanFilterNative(int center_x, int center_y);

Definition in processImage.cpp:

jintArray Java_fit_vutbr_faceswap_CameraPreview_kalmanFilterNative( JNIEnv* env, jobject thiz, jint center_x, jint center_y) 
{                   
  // code
  return ret;
}

And on call ret = kalmanFilterNative(center_x, center_y); I get UnsatisfiedLinkError: Native method not found .

Does anybody have a clue where is the problem?

Try to modify your native method to :

extern "C" {
    JNIEXPORT jintArray JNICALL Java_fit_vutbr_faceswap_CameraPreview_kalmanFilterNative( JNIEnv* env, jobject thiz, jint center_x, jint center_y);
};
    JNIEXPORT jintArray JNICALL Java_fit_vutbr_faceswap_CameraPreview_kalmanFilterNative( JNIEnv* env, jobject thiz, jint center_x, jint center_y) 
    {                   
      // code
      return ret;
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM