我想编译 bundle 在我的项目中的库。我遇到了两个问题。
第一个 Cmake 似乎没有检测/包含该目录。
第二个是在检测/包含 bundle 目录而不是android工具链之后,系统的一个用于编译库。
作为第一个问题的解决方法,我添加了 if(ANDROID)
添加该目录以便将其包含在内。
if(EXISTS "${CMAKE_SOURCE_DIR}/libs/CMakeLists.txt")
message(STATUS "Using bundled libraries located at ${CMAKE_SOURCE_DIR}/libs")
if(ANDROID)
add_subdirectory(libs)
else()
include(libs/CMakeLists.txt)
endif()
else()
所以对我来说,预期的结果应该是这样的,包括 libs/CMakeLists.txt 并使用 NDK 提供的工具链构建库
最佳答案
如果您尝试将非 ndk 预构建库用于 native 组件,则将这些库详细信息添加到 CMake 中,如下所述。
add_library( imported-lib
SHARED
IMPORTED )
set_target_properties( # Specifies the target library.
imported-lib
# Specifies the parameter you want to define.
PROPERTIES IMPORTED_LOCATION
# Provides the path to the library you want to import.
imported-lib/src/${ANDROID_ABI}/libimported-lib.so )
https://developer.android.com/studio/projects/configure-cmake#add-other-library
关于android - 在 Android Studio/Gradle 中编译 bundle 库的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55733321/