"jni" folder not found



When I start programming with OpenCV and Android NDK, I encountered an error with not found ‘jni’ folder in project which is critical to creation of application.


So I found my own way to solve that problem.

First of all you have to create a folder called 'jni'



Then you have to create an external tool configuration to configure jni. To do that you have to small arrow button external tool button in short cut bar.

Click the down arrow and select ‘External tool configuration’, you will end up window like below.


Press select Program and press new in upper corner which calls ‘New launch configuration’


Provide any appropriate name you like for ‘Name’. In ‘Location’, you must give your ndk-build file. So for that first select ‘Browse File System’


And then browse to your android ndk folder and select ndk-build file



Then for your ‘Working Directory’, you have to give your jni folder. So for that first you select ‘Browse Workspace’


And select your 'jni' folder in working project 

Then press ’Run’. Sometimes this will display some error message ignore that message. Even though we have create jni configuration but it still show the error that shows in console in start because there is no file that ‘jni’  folder and we have to configure them.

So, first thing we are going to do is create ‘Android.mk’. Go ahead and create ‘Android.mk’ file in jni folder.


Add something like this code, if you want more about Android.mk file go to your android ndk foler and there you will find folder called ‘docs’ in there you will able to find HTML file call ANDROID-MK, in that document, you are able to find details about your Android.mk file

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_LDLIBS := -llog 


LOCAL_MODULE    := ndksetup
LOCAL_SRC_FILES := native.cpp



include $(BUILD_SHARED_LIBRARY)


But we are not still finished. Then we are going to create our native.cpp without it console shows a message like this

  
So to fix this, we are creating file called ‘native.cpp’


In that file you have to write your OpenCV codes according to your program. (Writing code for native.cpp file is out of this post scope)

There is an additional file called ‘Application.mk’ but it is optional file to create.

Eventually, if you will see a message like this below in your console

Now, you are up and running with android ndk in you android app. 
Show Comments: OR

Post a Comment