Search code examples
androidconan

Using shared library with Conan.io within Android


I have a pre-built shared library (architecture ARM) which I exported as a conan package:

conan export-pkg .. ext/stable --force -pr android_19_arm_clang

Next I want to use this library in my Android project. I have Conan and CMake setup like this.

conanfile.txt:

[requires]
LibraryName/0.1@ext/stable

CMakeLists.txt

...
conan_basic_setup(NO_OUTPUT_DIRS)
...
target_link_libraries( # Specifies the target library.
                  myOwnAndroidLib-lib
                  android
                  ${CONAN_LIBS}
                  )
...

Since the the pre-built library is a ".so" library I have to put it into the jniLibs Folder of my Android project. This part is missing in the conan/Android docs. How can I instrument conan to place the *.so files in the jniLibs folder?

Thank you


Solution

  • If you want to copy pre-built packages to a specific folder when building, you should use the feature imports:

    https://docs.conan.io/en/latest/using_packages/conanfile_txt.html#imports

    https://docs.conan.io/en/latest/reference/conanfile_txt.html#imports