Android App Bundle(仅)- 本机库加载失败

Android App Bundle (only) - native library failed to load

我几个月前在 Google Play 制作中切换到 Android App Bundle (ABB) 并发布了几个更新 - 一切都很好。上周我进行了 Android Studio 更新并注意到只有 ABB 构建无法在运行时加载我的本地库之一。但是 APK 构建(发布)和调试构建可以正常加载本机库。

我被迫部署一个 APK 来替换生产中损坏的 ABB 版本。

我发现 ABB 包包含所有四个(arm64-v8a、armeabi-v7a、x86、x86_64)目录,我所有的 .SO 文件都在那里(与 APK 包中的相同)。

为了进一步调查,我编辑了 Android Studio 运行 配置以部署 'APK from app bundle' 并验证本机库无法加载仅用于 ABB 构建(其他构建模式很好).

我的环境:Android Studio 4.0(目前最新), 'io.fabric.tools:gradle:1.28.0'(ABB 一直工作到 1.26.1), compileSdkVersion 28, buildToolsVersion '28.0.3'

没有简单的方法来回滚最新更新。请让我知道如何解决此构建问题。感谢您的帮助。

终于找到了解决此问题的解决方法。我正在使用的 third-party 库不符合最近的 Gradle 更改。 Java 当从设备上的 ABB 构建 APK 时,库的代码不知道其 SO 文件的正确路径。 gradle.properties 文件中的设置效果很好。

根据 Gradle release note

When building an Android App Bundle, APKs generated from that app bundle that target Android 6.0 (API level 23) or higher now include uncompressed versions of your native libraries by default. This optimization avoids the need for the device to make a copy of the library and thus reduces the on-disk size of your app. If you'd rather disable this optimization, add the following to your gradle.properties file:

android.bundle.enableUncompressedNativeLibs = false