First, I have a JNIEXPORT method look like this:
JNIEXPORT void JNICALL Java_com_app_osap_Native_nativeProcessImage(JNIEnv *env, jobject thiz, jstring imagePath){
// ...
handle(data);
}
Then I write another method in the same cpp file:
void handle(int data[]){
}
But I get this error when compile source code:
'handle' was not declared in this scope
Please tell me what my problem is and how I can solve it.
Thanks in advance!
Since you don't use headers, you need to declare handle function before the JNI function. Or, you may start to use headers that will contain the declarations of the functions and then include it in your cpp file. Like:
test.h:
void handle(int data[]);
test.cpp
#include test.h
Don't forget to add the header to your module in your Android.mk:
include $(CLEAR_VARS)
LOCAL_MODULE := test
LOCAL_SRC_FILES := path/to/test.cpp
LOCAL_C_INCLUDES := path/to/test.h #This is the header file you created
include $(BUILD_SHARED_LIBRARY)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With