Android ABI 拆分迁移到 App Bundle

标签 android renderscript abi android-app-bundle

我计划从 ABI 拆分迁移到 App Bundle 功能。目前我正在使用这段代码:

def versionCodesAbi = ['x86': 1, 'x86_64': 2, 'armeabi-v7a': 3, 'arm64-v8a': 4]

    splits {
        abi {
            enable true
            reset()
            include "x86", "x86_64", "armeabi-v7a", "arm64-v8a"
            // "armeabi", "mips", "mips64" last three not needed and not supported currently
            universalApk true
        }
    }

    android.applicationVariants.all { variant ->
        variant.outputs.each { output ->
            def abi = versionCodesAbi.get(output.getFilter(OutputFile.ABI))
            if (abi != null) {
                output.versionCodeOverride =
                        abi * 1000 + variant.versionCode
            }
        }
    }

每个 ABI 提供 4 个 APK(+ 通用 APK)。使用此代码的原因是为了减小应用程序大小,因为 PanoWidget (使用 NDK)和

renderscriptTargetApi 28
renderscriptSupportModeEnabled true

删除拆分配置(+4001 到 versionCode)并构建 Bundle 后,我得到了 .aab 文件,该文件转换为 .apks(使用 bundletool )包含文件夹 standalones/。我在里面有四种“类型”的 APK,分别用于 x86、x86_64、armeabi-v7a 和 arm64-v8a ABI。现在一切看起来都很好。

现在我注意到应用程序代码根本没有使用 RenderScript,所以我认为使用 supportModetargetApi 是多余的.我已经删除了这两行,在设备/模拟器上进行了测试,一切正常。所以接下来我正在制作 Bundle,现在它在 .apks 存档中没有 x86_64 APK 版本......如果没有 RenderScript 支持,它应该被省略吗?我仍在使用 VrPanoramaView,它可能为每个 ABI 提供一些特定的 NDK 代码(在 GitHub 上看不到)...遗憾的是我没有用于测试的 x86(32 或 64)设备不,我害怕发布这个 bundle ...我是否缺少 smth,我什至需要 _64 版本吗?

最佳答案

编辑:

在 build.gradle 中删除这两个选项将删除 RenderScript 使用的 native 库:librsjni.solibRSSupport.so。将为所有 ABI 删除这两个库。

由于禁用 RenderScript 后,您仍然有 3 个 ABI,看起来您的应用程序依赖于其他使用 native 代码的库,但不提供 x86_64 架构的库,这就是 x86_64 目录消失的原因。这可能意味着您的应用程序以前从未在 x86_64 上正常运行,因为平台会加载 x86_64 目录,但会丢失一些 native 库。

最终,您应该确定哪个库带来了这些 native 库,看看它们是否也可以构建 64 位版本,但在短期内,不会有任何问题,因为 x86_64 设备也支持 x86(32 位)库。

上一篇:

如果您的 APK 中有任何 *.bc 文件,64 位库将从 APK 中删除,因为这些 RenderScript 文件仅为 32 位,无法在 64 位中加载过程。

如果您迁移到更新版本的 RenderScript,将不会生成 *.bc 文件,并且 64 位 native 库将再次出现在 APK 中。或者,如果您根本不需要 RenderScript,则完全删除这些文件。

关于Android ABI 拆分迁移到 App Bundle,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54627154/

相关文章:

android - Firebase 离线数据

android - Renderscript 不可调用函数

android - 在系统签名的应用程序中使用自定义 RenderScript

api - 传递的数组包含子程序中预期的更多元素

eclipse - 当我调试我的应用程序时,我经常遇到启动错误 : Failed to connect to remote VM

java - 将 Android 客户端连接到 NodeJS 中的套接字服务器时出错

android - 在 Android studio 1.0.1 with API @ 21 and SDKTools @ 21.1.2 添加 Renderscript 导致构建错误

c++ - 由于符号与 abi::cxx11 的链接问题?

c++ - C 结构体是否符合 ABI?

android - Android 中的手势分割