如何从 Android App Bundle 中排除 ABI?

git*_*gin 4 android gradle google-play android-app-bundle

我知道在 Gradle 中生成拆分时有一个排除 ABI 的选项,如下所示:

android {
  splits {

    // Configures multiple APKs based on ABI.
    abi {

      // Enables building multiple APKs per ABI.
      enable true

      // By default all ABIs are included, so use reset() and include to specify that we only
      // want APKs for x86 and x86_64.

      // Resets the list of ABIs that Gradle should create APKs for to none.
      reset()

      // Specifies a list of ABIs that Gradle should create APKs for.
      include "x86", "x86_64"
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

这里是splits配置的官方参考

现在,建议在将应用程序发布到 Play 商店时使用应用程序捆绑包,并且我没有看到任何通过使用 Gradle 或 Play 商店发布控制台从该捆绑包中排除 ABI 的选项。

到目前为止我发现的唯一线索是您可以启用/禁用特定的拆分变体。例如,以下是如何根据文档完全禁用 ABI 包分割:

android {
    // When building Android App Bundles, the splits block is ignored.
    splits {...}

    // Instead, use the bundle block to control which types of configuration APKs
    // you want your app bundle to support.
    bundle {
        abi {
            // This property is set to true by default.
            enableSplit = true
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

但没有提及如何禁用/启用特定的 ABI 集。

我已经abiFilters指定排除不支持的 NDK,但看起来它对 App Bundle 没有影响。

更新:我假设abiFilters正在指定要从应用程序包中排除的 AB​​I,但事实恰恰相反,它们的目的是列出要包含的 ABI。经过此澄清后,一切似乎都正常工作。

Pie*_*rre 6

abiFilters是要走的路。指定要包含的 ABI 列表,其他 ABI 将被排除。

您不需要 Android App Bundle 的“splits”块:它会被忽略。

如果这对您不起作用,那么您能否提供 Gradle 配置集abiFilters,并说明如何确定 App Bundle 中存在的 ABI?