为什么 Cordova/Phonegap 将 8 附加到我的 Android 版本代码? [英] Why does Cordova/Phonegap append 8 to my Android Version Code?

查看:34
本文介绍了为什么 Cordova/Phonegap 将 8 附加到我的 Android 版本代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在处理一个 Cordova 项目,并且遇到了一个问题,即 8 被神秘地附加到了我的项目的 versionCode 中.例如:我原来的版本号是100,新的版本号是1008

I am currently working on a Cordova project and had the problem that 8 was appended mysteriously to the versionCode of my project. For example: My original Version code was 100, the new Version code is 1008

我通过我的整个构建管道跟踪了问题,并在 Gradle Build 脚本中找到了负责的代码.

I tracked the problem through my whole build pipeline and found the responsible code in the Gradle Build script.

if (Boolean.valueOf(cdvBuildMultipleApks)) {
    productFlavors {
        armv7 {
            versionCode cdvVersionCode ?: defaultConfig.versionCode + 2
            ndk {
                abiFilters "armeabi-v7a", ""
            }
        }
        x86 {
            versionCode cdvVersionCode ?: defaultConfig.versionCode + 4
            ndk {
                abiFilters "x86", ""
            }
        }
        all {
            ndk {
                abiFilters "all", ""
            }
        }
    }
} else if (!cdvVersionCode) {
  def minSdkVersion = cdvMinSdkVersion ?: privateHelpers.extractIntFromManifest("minSdkVersion")
  // Vary versionCode by the two most common API levels:
  // 14 is ICS, which is the lowest API level for many apps.
  // 20 is Lollipop, which is the lowest API level for the updatable system webview.
  if (minSdkVersion >= 20) {
    defaultConfig.versionCode += 9
  } else if (minSdkVersion >= 14) {
    defaultConfig.versionCode += 8
  }
}

我不确定为什么cordova认为更改我的版本代码是正确的,此外,我不确定这种行为是否正确......它不应该添加数字而不是附加它吗?

I am not sure why cordova thinks it is correct to change my version code, and additionally, I am not sure if this behaviour is correct ... shouldnt it add the number and not append it?

我可以删除 build.gradle 中的相应部分吗?或者这种行为背后有什么隐藏的意义吗?

Can I just remove the corresponding section in the build.gradle or is there some hidden sense behind this behaviour?

推荐答案

O.K.似乎这是 Cordova 版本 5 及更高版本中一个未解决的主要错误.这是票的链接.

O.K. seems like this is a major unresolved bug in Cordova Version 5 and up. Here is the link to the ticket.

从我的 build.gradle 中删除有问题的代码时我没有问题

I had no problem when removing the offending code from my build.gradle

这篇关于为什么 Cordova/Phonegap 将 8 附加到我的 Android 版本代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆