You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android AAR构建流程能否包含libssl.so.1.1?

Fixing Missing libssl.so.1.1 in Android AAR Built with OpenSSL 1.1.0

Hey there, let's break down what's going on here and how to get that missing .so.1.1 file into your AAR.

Why libssl.so.1.1 is Missing

First off, the core issue ties to how Android's build tools handle shared libraries, combined with OpenSSL 1.1.0's default output behavior:

  • OpenSSL 1.1.0 generates two SSL-related files: libssl.so.1.1 (the actual compiled shared library) and libssl.so (a symbolic link pointing to the versioned .so.1.1 file).
  • By default, Android build tools like Gradle's NDK plugin filter out shared libraries with version suffixes (like .so.1.1) when packaging AARs. They prioritize unversioned .so files, which align with Android's standard library loading expectations.

How to Include libssl.so.1.1 in Your AAR

Here are a few practical fixes to ensure the versioned library gets packed properly:

1. Manually Copy the Versioned Library to JNI Libs Directory

  • Navigate to your OpenSSL build output directory for each target Android architecture (e.g., armeabi-v7a, arm64-v8a).
  • Locate libssl.so.1.1 and copy it into the corresponding src/main/jniLibs/<architecture>/ directory of your Android library module.
  • Rebuild your AAR—Gradle will now include this file since it’s in the standard JNI libs location.

2. Adjust Gradle Configuration to Include Versioned .so Files

Modify your module's build.gradle (or build.gradle.kts) to explicitly include files with version suffixes:

android {
    sourceSets {
        main {
            jniLibs.srcDirs += 'path/to/your/openssl/build/outputs'
            jniLibs.include '**/*.so', '**/*.so.*' // Include both unversioned and versioned .so files
        }
    }
}

This tells Gradle to pick up all .so files (including versioned ones) from your OpenSSL build directory.

3. Tweak OpenSSL Build to Generate Unversioned .so Directly

If you don’t strictly need the versioned file, adjust the OpenSSL build process to output libssl.so as the primary library (instead of a symlink):

  • When configuring OpenSSL for Android, add the --libdir=lib flag to override the versioned output:
./Configure android-arm64 no-ssl2 no-ssl3 --prefix=/path/to/installation --libdir=lib
make && make install

This generates libssl.so directly as the compiled library, eliminating the need to include the versioned file altogether.

Final Check

After applying any of these fixes, unpack your generated AAR (rename it to .zip and extract) to verify that libssl.so.1.1 is present in the jniLibs directory for each target architecture.

内容的提问来源于stack exchange,提问作者Sean

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 04:13:11