![]() APP_ABI := all – sets the compilation for all the supported CPUs.Not necessary for the compilation, but in our case we specified: include $(BUILD_SHARED_LIBRARY) – ensures that shared library becomes a part of this make.LOCAL_SRC_FILES := native_lib – file that will be compiled in your module, no need to specify headers, the system will take care of it.LOCAL_MODULE :=native_lib– sets the name that is used as the identifier for a module, which is later used in Java.include$(CLEAR_VARS) – clears all variables that might be set from a previous module build.The macro ‘ my-dir’ is the directory of the Android.mk file. LOCAL_PATH := $(call my-dir) - Android.mk must begin with this definition, this defines the location of the sources.so package, we need to define an Android.mk file in our jni directory.Īndroid.mk file describes to the build system about your sources. ![]() We need to return a Java object, so we are doing it through the JniEnv pointer by calling a NewStringUTF() method. Notice that we are returning jstring which is different from C string in our method. ![]() Return (*env)->NewStringUTF(env, " Hello from JNI!") JNIEXPORT jstring JNICALL Java_ndk_NDK_1Methods_SayHello(JNIEnv *env, jobject thiz ) specifies the header file that is included #include Step 1: Declare Native Method in Java Classįirst thing that we need to do is to create a native method declaration in our Android application class.
0 Comments
Leave a Reply. |