如何在 Google Play 商店中使用本机库订购多个 APK?

How to order multiple APKs with native libraries in Google Play Store?

我的应用程序使用 4 个本机库(armeabi、armeabi-v7a、x86、mips)。我将 4 个独立的 APK 上传到 Google Play 商店,版本代码顺序如下:

在 Google Play 商店中,我收到了这条警告消息:

Some devices with Native platforms containing any of [x86] are eligible to receive version 102, which is better optimized for the device's Native Platform, but actually receive version 104 because it has a higher version code and the device supports Native platforms containing any of [armeabi-v7a] either directly (e.g. ARMv7 devices support a superset of ARMv5TE instructions) or indirectly (e.g. some x86 devices support ARMv7 or ARMv5TE via native code translation). This would occur when 
API levels in range 7+ and 
Screen layouts containing any of [small, normal, large, xlarge] and 
Features containing all of [android.hardware.TOUCHSCREEN].
Some devices with Native platforms containing any of [x86] are eligible to receive version 102, which is better optimized for the device's Native Platform, but actually receive version 103 because it has a higher version code and the device supports Native platforms containing any of [armeabi] either directly (e.g. ARMv7 devices support a superset of ARMv5TE instructions) or indirectly (e.g. some x86 devices support ARMv7 or ARMv5TE via native code translation). This would occur when 
API levels in range 7+ and 
Screen layouts containing any of [small, normal, large, xlarge] and 
Features containing all of [android.hardware.TOUCHSCREEN].
Some devices are eligible to run multiple APKs. In such a scenario, the device will receive the APK with the higher version code.

是不是我的版本号顺序不对?什么是好的订单?

在您的示例中,您需要按如下方式订购 ABI:

  • armeabi 101
  • armeabi-v7a 102
  • mips 103
  • x86 104

注意:您仍然会收到警告,某些设备有资格运行多个 APK 事实上,armeabi-v7a 设备也可以 运行 armeabi 版本,但会安装最高版本的 APK。

armeabi (101) 的版本低于 armeabi-v7a (102) 很重要,否则您的 armeabi-v7a 设备将安装 armeabi 版本并且性能会很差。同样重要的是 x86 是比 armeabi-v7a 更高的版本,因为 x86 可能(或可能不)支持 armeabi-v7a。

您可以考虑将 ABI 代码添加为版本的前缀(如下图所示)。这使您可以发布一个 ABI 的更新,而无需更新所有 APK。

这些版本号可以在您的 Android gradle 构建中自动生成。

project.ext.versionCodes = ['armeabi': 1, 'armeabi-v7a': 2, 'arm64-v8a': 3, 'mips': 5, 'mips64': 6, 'x86': 8, 'x86_64': 9]

android.applicationVariants.all { variant ->
        variant.outputs.each { output ->
            output.versionCodeOverride =
                project.ext.versionCodes.get(output.getFilter(
                    com.android.build.OutputFile.ABI), 0) * 10000000 + android.defaultConfig.versionCode
    }
}

您可以在我发布的 this article 中阅读有关如何实施此版本控制系统的更多信息。

可以找到有关使用本机库部署应用程序的更多信息here

可以在 Android 构建系统中找到有关 ABI 拆分的文档 here