I haven't found anyone who has been able to answer my specific question online. I have an old Android project that I want to copy some .so libraries from and paste them into a new project. I'm new to this stuff and I know I need to tell my new program where to find these libraries but I don't know if I should be using CMake or NDK to import alreay compiled code. This is what my directory looks like:
I call for this library in my program like this:
static {
System.loadLibrary("serial_port");
}
But how do I tell the compiler where to find these copied and pasted files?
I started a file based on the documentation from Android but I'm confused about a few things. This is what I have so far:
# Sets the minimum version of CMake required to build your native library.
# This ensures that a certain set of CMake features is available to
# your build.
cmake_minimum_required(VERSION 3.4.1)
# Specifies a library name, specifies whether the library is STATIC or
# SHARED, and provides relative paths to the source code. You can
# define multiple libraries by adding multiple add.library() commands,
# and CMake builds them for you. When you build your app, Gradle
# automatically packages shared libraries with your APK.
add_library( # Specifies the name of the library.
serial_port
# Sets the library as a shared library.
SHARED
IMPORTED
serial_port/src/${ANDROID_ABI}/libserial_port.so
# Provides a relative path to your source file(s).
src/main/cpp/libs/armeabi/libserial_port.so )
I don't think I'm doing it right. Please take a look and point me in the right direction. Thanks
You need to keep them inside the dir jniLibs
in their respective folders.
eg.
/app/src/main/jniLibs/armeabi/libserial_port.so
And you don't need to use any other tools like CMake to use them. You can directly load them.