- I have created a simple JNI project,
- I create test.cpp file and inside it I created
Java_com_etc_function1()
- I used
CMakeLists.txt
to create test.so shared library - I loaded the shared library in MainActivity using
System.LoadLibrary('test');
- I called
public native void function1()
successfully. - when I run
nm.exe -D test.so
, I can confimJava_com_etc_function1()
exists.
Everything is ok until I decided to replace the CMakeLists.txt
file with Android.mk
file.
When ever I change my app gardle file to point to :
ndkBuild {
path 'src/main/jni/Android.mk'
}
instead of CMakeLists.txt,
my project stills build the test.so library, and when I run nm.exe -D test.so
I also can confirm that Java_com_etc_function1()
exists in it, and am still able to load the library in MainActivity.java , but the problem is : I am not able to call: public native void function1()
, its in red color, error: cannot find matching JNI function Java_com_etc_function1() , and when I press Alt + Enter -> choose create function - Nothing happens.
This is my Android.mk file below,
Android.mk file:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := test
LOCAL_EXPORT_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)
Application.mk file:
APP_OPTM := release
APP_ABI := all
APP_PLATFORM := android-21
I think I am missing 1 more step to do to be able to call this function from MainActivity.java , but I still can't figure out. Please if you can help me.
Thanks.