In an Android project that loads a C library (mylib.so, which includes a JNI API already), I have a CMakeLists.txt that import the prebuilt library, as per the documentation, like so:
cmake_minimum_required(VERSION 3.10.2)
project(ImportMyLib)
set(MYLIB_PREBUILT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/build/arm64/src")
add_library(mylib SHARED IMPORTED)
set_target_properties(mylib
PROPERTIES IMPORTED_LOCATION
"${MYLIB_PREBUILT_PATH}/libmylib.so")
I did print ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/build/arm64/src
and checked that ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/build/arm64/src/libmylib.so
does exist.
However, libmylib.so
is not included in the resulting .aar
, and I don't understand why.
My build.gradle
does include the CMakeLists.txt above, like so:
externalNativeBuild {
cmake {
path "src/main/cpp/CMakeLists.txt"
}
}
This is similar to this question, except that it seems there that there was a need to add an IMPORTED
target (because of the ExternalProject_Add
), whereas here I'm trying to import an already built library.
What am I missing?