I have developed an application for computer vision algorithms that uses Native C++
library like OpenCV
to capture camera frame and do image processing. My whole implementation resides in a native function which is called through an activity.
Let's say:
public native int MYMETHOD(int width, int height,int[] rgba);
I also load my library like this:
static {
System.loadLibrary("MYNativeLIB");
}
Now my question is how can I deploy my application as a library package. Something deliverable that I can share it and the clients can import it to their project without installing any other libraries like OpenCV
. Do I need to build a .so
package?
I have read this article. But I do not know how can I link against OpenCV
library as well.
Thanks for your help in advance.
An Android library module can contain Java classes, Android components and resources. Only assets are not supported. The code and resources of the library project are compiled and packaged together with the application.
The main difference is aar is splitted inside android to jar. If your app will be used only in user app only in android studio then aar is preferred. If you are planning for app to communicate with c/c++ compiled lib.so file jar is preferred.
You are developing an Android app on Android Studio, sometimes you want to use an external library for your project, such as a jar file. Common langs is an java library with open source code which is provided by the Apache, it has utility methods for working with String, numbers, concurrency ...
Click File > New > New Module. In the Create New Module window that appears, click Android Library, then click Next . There's also an option to create a Java Library, which builds a traditional JAR file.
To use your new Android library's code in another app or library module within the same project, add a project-level dependency: Navigate to File > Project Structure > Dependencies. Select the Module in which you’ll use the library. In the Declared Dependencies tab, click and select Module Dependency in the dropdown.
Create a library module. 1 Click File > New > New Module. 2 In the Create New Module window that appears, click Android Library, then click Next . 3 Give your library a name and select a minimum SDK version for the code in the library, then click Finish.
Let us have an external library that we want to use in our project i.e a jar file. Create a new project named GFGAddLib. Now, our project has been created. Now click on the Android drop-down and change to Project files. Click on Project files.
You should have a look at the static initialization for OpenCV4andorid. You then can add the Open CV lib into your /libs directory of your Library project without the need to install any third party app when using it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With