As mentioned in RN version 0.59.9 changelog, one should be able to upgrade to Gradle 5.4.1 & Android Gradle plugin to 3.4.0. This works and builds just fine, but I noticed that when I switch between Gradle 4.10.2 and 5.4.1, then the versionCode for my app bundle changes to a different (lower) number (I have enableSeparateBuildPerCPUArchitecture set to true).
This is an issue because I have already published versions of the app which build with a higher number so Google does not allow me to use these new builds. This only happens when using Gradle 5.4.1 and changes to the "correct" build number when I switch back to the older version.
I did some testing and (afaik) the issue appears to be on the order that the ABI variants are processed. So with version 4.10.2, the last ABI to get evaluated in the "each" loop (app/build.gradle) is "x86_64", which would return number 4 from versionCodes.get(abi) and so the versionCodeOverride would end up being: 4 * 1048576 + versionCode.
When using Gradle 5.4.1, then I get a final: 3 * 1048576 + versionCode, implying that the last ABI to get evaluated was "arm64-v8a" (number 3) even if all 4 default ABIs are enabled and in the same order.
I don't know much about Gradle and build scripts so maybe I'm missing something, but it seemed strange enough for me to open an issue.
React Native version:
0.59.9
React Native Environment Info:
System:
OS: Windows 10
CPU: (4) x64 Intel(R) Core(TM) i5-4590 CPU @ 3.30GHz
Memory: 9.07 GB / 15.87 GB
Binaries:
Yarn: 1.16.0 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.4.1 - C:\Program Files\nodejs\npm.CMD
IDEs:
Android Studio: Version 3.4.0.0 AI-183.6156.11.34.5522156
Describe what you expected to happen:
versionCode should be the same for builds in steps 3 and 4
You don't need enableSeparateBuildPerCPUArchitecture if you use app bundle, so please disable it. See https://developer.android.com/platform/technology/app-bundle.
@juanamd did you solve this? I'm having the exact same issue.
@juanamd did you solve this? I'm having the exact same issue.
As @dulmandakh suggested, I disabled enableSeparateBuildPerCPUArchitecture since it wasn't really necessary when using app bundle.
What if I already have apps published to Play Store with APK splitting? For example I have a versionCode 30, therefore:
armeabi-v7a - 1048606
x86 - 2097182
arm64-v8a - 3145758
x86_64 - 4194334
Once I build .abb I get a single 3 1048576 + versionCode file.
Should I turn off enableSeparateBuildPerCPUArchitecture and manually update versionCode to 4 * 1048576 + versionCode? Looks hacky, but otherwise, x86_64 users won't get an update. 馃槩
@juanamd did you have the same problem/solution?
@rosskhanas I turned off enableSeparateBuildPerCPUArchitecture and manually replaced my versionCode with the latest in Play Store + 1, 4194334 + 1 in your case. Then just increment it with every build. I don't know if there's a fancier way of doing it.
This is really bad, now my Android version code is over 4194306....
@juanamd @dulmandakh I'm having the exact same issue, and
def enableSeparateBuildPerCPUArchitecture = false
doesn't do any difference. Any ideas?
Update: Our problem was that we had these per-apk version codes that had been obsolete for a while, since we're using app bundles. For some reason, this resulted in different app bundle version codes for Gradle 4 vs 5. We removed the version code logic and then the bundle's version code became predictable.
Most helpful comment
@rosskhanas I turned off enableSeparateBuildPerCPUArchitecture and manually replaced my versionCode with the latest in Play Store + 1, 4194334 + 1 in your case. Then just increment it with every build. I don't know if there's a fancier way of doing it.