
To know detail about this file read from this link Īpplication.mk which describes the native modules that your app requires.ĪPP_ABI := armeabi-v7a armeabi arm64-v8a mips mips64 x86 x86_64 LOCAL_SRC_FILES := application_com_ndkapplication_NativeClass.cpp JNIEXPORT jint JNICALL Java_application_com_ndkapplication_NativeClass_exampleĪnd for this example no need to add any function in its header file.Ĭreate a new file named Android.mk and Application.mk in Jni folderĪndroid.mk file is to describe your sources to the build system. Here I am for simple example just adding two numbers and returning value to android java.Īpplication_com_ndkapplication_NativeClass.cpp #include c file of same name of header file in jniĭelete everything before **JNIEXPORT line** in this file and **add header file name** alone. You will find jni folder created and a header file will be created with the name you specified in terminal before as shown below jni -Generate JNI-style header file (default) When you build, you will find the class file created under build like this, Here I written function as example and given two integer input to it, Write a simple calling function with function name and input for the function, Here I created java file named NativeClass Now, create a new Java Class file under a app/src/main/java , Now you will find under app-build–intermediates–classes–debug folder, as shown below. Next, again Build – Make Project (Ctrl + f9). Path will extend from project path to main. Then in Terminal, initially it will contains project’s path Your project will be successfully build and will get BUILD SUCCESFUL in message Then, Press Build – Make Project (Ctrl + f9). In gradle – local properties add location of sdk path like sdk.dir=F\:\\gowtham\\Android\\sdk Next, to integrate NDK with Android Studio, after creating a new android project, Īfter downloading, give the path in System Environment Variable as variable name “ NDK_PROJECT_PATH” and variable value “location of NDK stored path”. Here I will give process flow for manually install NDK and an example code,īased on your System OS you can download NDK from this location. You can use NDK by manually downloading NDK and build it or through CMake. Using Android Studio 2.2 and higher Native Development Kit (NDK) you can use to compile C and C++ code. Getting started with Android NDK with simple example
