我刚刚为我的 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/