Android: Can not link external static library

  android-build, android-studio, c++, external-library

I am trying to add an external static library to my android project based on this post: Android: Linking a external static C/C++ Library in Android Studio

name of the file is liblogger.a and I added the following lines in CMakeList.txt:

add_library(logger_lib STATIC IMPORTED)
.
.
.
set_target_properties(logger_lib PROPERTIES IMPORTED_LOCATION ${SPICABASE}/include/liblogger.a)
.
.
.
target_link_libraries( # Specifies the target library.
                       native-lib
                       logger_lib
                       .
                       .
                       .

Name of the function that I am calling from the external static library is log_debug.
Currently I am having the following error:

Error:(966) undefined reference to 'log_debug(char const*, ...)'
Error:error: linker command failed with exit code 1 (use -v to see invocation)

And I am sure that it can find the library because when I change the name or address it gives me the following different error:

Error:error: 'C:/Worldline/sdk/extras/worldline/ndk/2018.18.00/platforms/android-19/include/another_name.a', needed by '../../../../build/intermediates/cmake/debug/obj/armeabi-v7a/libnative-lib.so', missing and no known rule to make it

Could some one please explain what I should do?

Source: Windows Questions C++

LEAVE A COMMENT