Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Before trying to include c++ OpenCV to an Android Studio Project I highly recommend you to make yourself familiar with the NDK and JNI. Look up Android NDK for that. To see a Code example for that you can also look up the Samples Android Studio gives to you.

What you need to do:

Install the Android NDK, if you haven't done this already. You can find it through SDK Manager -> Android SDK -> SDK Tools. Download the Hello-JNI Sample after that. You can get it through the "Import an Android code sample" In the "Welcome to Android Studio" Window.

The Hello-JNI Project, shows you the basic usage of the NDK/JNI Combination for native development.

After you understand that, look up the Building Guide from the Android NDK page. There you will learn how to change and update the Android.mk and Application.mk which are necessary to add a Library or .cpp/.c/.hpp/.h files to your Application.

After that, you should be able to add OpenCV to your Android Application through: - get builded Libraries - change the Android.mk that it adds the needed Libraries - add the Libraries through `static{ System.loadLibrary("librarynamespace defined in the Android.mk")}" - Build your Application - Run and have fun!

Also I would suggest you, to add a .cpp File into your Android Studio Project, where you make every JNICALL. Android Studio does not (until now) Support Cpp Debugging and Syntax but when you are familiar with c++ it wont make any problem.

So far that should be everything you need to know about that. AFAIK the OpenCV .so should be addable just like ervery other librariy through the android.mk

Before trying to include c++ OpenCV to an Android Studio Project I highly recommend you to make yourself familiar with the NDK and JNI. Look up Android NDK for that. To see a Code example for that you can also look up the Samples Android Studio gives to you.

What you need to do:

Install the Android NDK, if you haven't done this already. You can find it through SDK Manager -> Android SDK -> SDK Tools. Download the Hello-JNI Sample after that. You can get it through the "Import an Android code sample" In the "Welcome to Android Studio" Window.

The Hello-JNI Project, shows you the basic usage of the NDK/JNI Combination for native development.

After you understand that, look up the Building Guide from the Android NDK page. There you will learn how to change and update the Android.mk and Application.mk which are necessary to add a Library or .cpp/.c/.hpp/.h files to your Application.

After that, you should be able to add OpenCV to your Android Application through: - get builded Libraries - change the Android.mk that it adds the needed Libraries - add the Libraries through `static{ System.loadLibrary("librarynamespace defined in the Android.mk")}" - Build your Application - Run and have fun!

Also I would suggest you, to add a .cpp File into your Android Studio Project, where you make every JNICALL. Android Studio does not (until now) Support Cpp Debugging and Syntax check but when you are familiar with c++ it wont make any problem.

So far that should be everything you need to know about that. AFAIK the OpenCV .so should be addable just like ervery other librariy through the android.mk