Android App Bundle版本代码突然很高

标签 android react-native build version

我刚刚为我的 React Native 应用程序制作了一个新的 Android 包。我在 android/app/build.gradle 中手动将版本代码从 90 更新为 91,但现在我尝试上传到 Play 商店,版本代码是 3145819(我预计会看到 91)

构建.gradle:

 defaultConfig {
        applicationId "com.myapp"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 91
        versionName "4.1.0"
        multiDexEnabled true
        missingDimensionStrategy "RNN.reactNativeVersion", "reactNative57_5"
        resValue "string", "build_config_package", "com.myapp"
    }

我使用这个命令来 bundle :

./gradlew bundleProdRelease --console plain

不知道为什么会发生这种情况,而且我绝对更喜欢较小的版本代码(用户在报告错误时更容易阅读)。

知道这里发生了什么以及如何解决它吗?

最佳答案

哦哦,好吧,我终于明白了!不,过去两年我并没有拼命寻找答案......我现在只是不知何故偶然发现了它。

因此,在android/app/build.gradle中,有一个生成bundle版本代码的脚本。它是根据版本代码和目标架构版本代码计算得出的。例如在 RN 0.64x template :

def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
def abi = output.getFilter(OutputFile.ABI)

if (abi != null) {
  output.versionCodeOverride = defaultConfig.versionCode * 1000 + versionCodes.get(abi)
}

对我来说,arm64-v8a 在生成版本代码时似乎总是被用作默认值,因此我得到如下输出:

versionCode 1 => 1003
versionCode 12 => 12003
versionCode 105 => 105003
you get the idea...

过去的计算涉及一个更加神秘的数字(1048576 🔮🧙‍♂️,请参阅 RN 0.59x template ),这看起来很随意,并且很难理解这个 bundle 版本的代码已生成。

现在它更有意义了!

关于Android App Bundle版本代码突然很高,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56898914/

相关文章:

react-native - 升级到 React Native 0.59 后,Apple 拒绝了二进制文件(2.3.1 - 性能)

sql - 获取定义相等时间段的记录的总和/平均值

jenkins - 用于在Android Studio项目中构建的管道脚本

来自 Play 商店的 Android 应用程序更新

android - CSS 背景不会在普通的 Android 浏览器上重复?

android - 在 linux centos 平台上使用 Jenkins 和 Gradle 构建 Android 应用程序时出错

java - 应用程序名称在设备上看起来很奇怪

react-native - 使用 React Native 检测从应用程序设置/后台返回

react-native - 无法解析模块 prop-types,但 grep prop-types 没有显示任何内容

build - 如何在Gradle中的依赖项组上指定属性?