可以尝试在工程的CMakeLists.txt文件中手动添加OpenSSL库的include路径,以解决找不到include文件的问题。具体步骤如下:
dependencies {
implementation 'org.conscrypt:conscrypt-android:2.5.1'
}
find_library( # Defines the name of the path variable that stores the
# location of the NDK library.
ssl-lib
# Specifies the name of the NDK library that
# you want CMake to locate.
ssl)
find_library( # Defines the name of the path variable that stores the
# location of the NDK library.
crypto-lib
# Specifies the name of the NDK library that
# you want CMake to locate.
crypto)
# 引用OpenSSL库
target_link_libraries(your-project ssl-lib crypto-lib)
# 设置include路径
target_include_directories(your-project PRIVATE path-to-openssl-include-dir)
其中,path-to-openssl-include-dir为OpenSSL库中include文件所在的路径。
通过以上步骤,即可成功引用OpenSSL库并设置include路径,解决编译时找不到include文件的问题。