Option 1:
If it makes a difference, you do not have to include the -jni
option. It's the default option for javah
.
javah -classpath bin/classes/ -d jni/ com.example.test_ndk.FibLib
Option 2:
The other alternative would be to create the header file yourself, but this is not an easier option. Your header would look like this (there's a 1 before ndk
in test_1ndk
because you used an _
character in the package name. If we don't put it, the caller will look for a folder called ndk
inside a folder called test
, therefore, I wouldn't recommend using test_ndk as your package name. Instead use testNdk or something with the underscore):
#include <jni.h>
JNIEXPORT jlong JNICALL Java_com_example_test_1ndk_FibLib(JNIEnv*, jclass, jlong);
// use jobject instead of jclass if your method is non-static
And the general format is:
JNIEXPORT [returnType] JNICALL Java_[package name with folders separated by _]_[class name]_[method name] (JNIEnv*, jclass, jtype arguments);