I have an Android NDK project which builds libMyProject1.so and I am using:


to export the built library to the folder that I need.

I also have another external shared library that I link with:

MyExternal library

add_library(MyExternal SHARED IMPORTED)
set_target_properties(MyExternal PROPERTIES IMPORTED_LOCATION        ${CMAKE_CURRENT_SOURCE_DIR}/../MyExternal/libs/${ANDROID_ABI}/libMyExternal.so)

target_link_libraries( # Specifies the target library.
        # Shared Dependencies
        # Links the target library to the log library
        # included in the NDK.

libMyProject1.so is copied to Client/libs/${ANDROID_ABI} but libMyExternal.so is not copied. How to copy the external shared library to my client folder using cmake?


As suggested in the comments, the following worked for me:

file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/../MyExternal/libs/${ANDROID_ABI}/libMyExternal.so
  • 1
Reply Report

You should change the jniLibs.srcDirs, which will be packed by the gradle.

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        ndk {
            abiFilters 'armeabi', 'armeabi-v7a', 'arm64-v8a'
    sourceSets {
        main {
            // let gradle pack the shared library into apk
            jniLibs.srcDirs = ['Client/libs/']
    externalNativeBuild {
        cmake {
            path "CMakeLists.txt"

dependencies {
  • 0
Reply Report

Warm tip !!!

This article is reproduced from Stack Exchange / Stack Overflow, please click

Trending Tags

Related Questions