I have an application I'm trying to compile, which uses *.c files.
To compile this I must use NDK.
Downloaded the 64bit version and browsed the net to find tips on configuring gradle.
It seems the config is ok, and gradle attempts to run the NDK build process.
It does this by calling ndk-build.cmd and stops with this error:
\AppData\Local\VirtualStore\Windows\SysWOW64\android-ndk-r10d\ndk-build.cmd": CreateProcess error=2, The system cannot find the file specified
I searched the whole folder for ndk-build.cmd, but there is none.
What in the world am I missing?
EDIT1: The NDK is installed here:
#ndk.dir=C\:\\Users\\user\\AppData\\Local\\VirtualStore\\Windows\\SysWOW64\\android-ndk-r10d
EDIT2: I did try my system path is OK, this is not the problem. I did however instal the 32-bit version, and this one does have the *.cmd file.
I can now compile the *.c files.
I used this command in the AndroidStudio Terminal:
ndk-build -C C:\Users\Thatisme\AndroidStudioProjects\DeezerAP2\app\src\main\jni
All *.c, *.h, *.mk and *.sh were placed in the jni folder as seen in the picture bellow.
EDIT3: I can now generate *.so files, but for some reason, the native methods are not found.
EDIT4:
This is how my project looks like:
I manually copied the *.so files in the jniLibs folder.
Is the declaration of the *.c function OK?
JNIEXPORT jobject JNICALL Java_com_lexample_liggy_ldeezerap_SerialPort_open
(JNIEnv *env, jclass thiz, jstring path, jint baudrate, jint flags)
EDIT5: I finally did it. The correct name of the function is:
JNIEXPORT jobject JNICALL Java_com_example_iggy_deezerap_SerialPort_open
(JNIEnv *env, jclass thiz, jstring path, jint baudrate, jint flags)
Package name is: com.example.iggy.deezerap
Java file calling the function "open()" is: SerialPort
The source file containing the native function is named: SerialPort.c
The function beeing called is: open()
I recompiled the *.c files, copied them also in jniLibs, recompiled the Android project and now it works.
I'm pretty sure I had this before and I strongly suspect it was due to some sort of mismatch error in the *.c functions.
About the thing in bold:
JNIEXPORT jobject JNICALL Java_com_example_iggy_deezerap_SerialPort_open (JNIEnv *env, jclass thiz, jstring path, jint baudrate, jint flags)
Does this refer to the *.c file or the *.java file?
native open(...)
function is located. – tlau