Android Studio CMake – shared library missing libc++_shared.so? Can CMake bundle this?

I just add this script to moudle’s build.gradle:

externalNativeBuild {
        cmake {
            cppFlags ""
            arguments "-DANDROID_STL=c++_shared"
        }
    }

it will package ‘libc++_shared.so’ in the apk file

I wrote a CMake config that should package the STL files:
https://github.com/jomof/ndk-stl/blob/master/ndk-stl-config.cmake

Copy this file next to your CMakeLists.txt and inside CMakeLists.txt do

include(ndk-stl-config.cmake)

Let me know if you have problems

add this in your build.gradle (Module: app)

externalNativeBuild {
            cmake {
                cppFlags "-std=c++14 -fexceptions -frtti"
                arguments "-DANDROID_ARM_NEON=TRUE",'-DANDROID_STL=c++_shared'
            }
        }

Leave a Comment