问题
I just made a new Android bundle for my React Native app. I manually updated the version code from 90 to 91 in android/app/build.gradle, but now that I am trying to upload to Play Store, the version code is 3145819 (I expected to see 91)
build.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"
}
I use this command to bundle:
./gradlew bundleProdRelease --console plain
Not sure why this is happening, and I definitely prefer a smaller version code (easier for users to read when reporting bugs).
Any idea what's going on here and how to fix it?
回答1:
I had the same issue. It occurred whenever I ran ./gradlew bundleRelease and I changed
def enableSeparateBuildPerCPUArchitecture = false
to
def enableSeparateBuildPerCPUArchitecture = true
This function is found in android/app/build.gradle
I am unsure how to stop it doing it aside from changing enableSeparateBuildPerCPUArchitecture back to false
回答2:
One possibility is that your /app/build.gradle
config contains some logic that transforms the versionCode likely because you are doing app bundling.
In the current master of react-native, you can see some versioning logic here.
Possibly your build.gradle has the same or similar logic.
Google has there explanation on versioning here.
来源:https://stackoverflow.com/questions/56898914/android-app-bundle-version-code-suddenly-very-high