How does `bundletool build-apks` generate the versionCode for the APKs?
fabiendem opened this issue · 3 comments
Hi,
I want to use the command bundletool build-apks --bundle=/MyApp/my_app.aab --output=/MyApp/my_app.apks
but it's not clear to me which versionCode
will be generated for those APKs.
There is parameter specified at https://developer.android.com/tools/bundletool#generate_apks
Afaik, when you generate the different APKs, each should have a different versionCode
, see https://developer.android.com/google/play/publishing/multiple-apks#VersionCodes
Can one explain how it works while using the bundletool?
I browsed the source code but I couldn't find anything useful to answer.
If they all have the same versionCode
, what's the recommended way to edit this once I have the APKs?
Thank you!
It uses the same versionCode
in all split APKs because the versionCode
s need to be the same for them to be installable. From https://developer.android.com/reference/android/content/pm/PackageInstaller:
Apps packaged as multiple split APKs always consist of a single "base" APK (with a null split name) and zero or more "split" APKs (with unique split names). Any subset of these APKs can be installed together, as long as the following constraints are met:
- All APKs must have the exact same package name, version code, and signing certificates.
- ...
Afaik, when you generate the different APKs, each should have a different
versionCode
, see https://developer.android.com/google/play/publishing/multiple-apks#VersionCodes
The "multiple APKs" being referred to here are different from the split APKs generated by bundletool. This link refers to creating multiple, separate monolithic APKs which contain all necessary resources for a given device target and can be installed individually. The split APKs generated by bundletool are installed simultaneously, and only the appropriate subset of them are downloaded and installed by the device.
Thank you!
Thanks for linking the doc, I missed that.
I realised that my mental model was wrong after watching those videos as well:
I am transitioning from APK to AAB on an existing app.
I have used a large number for one of the Abis versionCode
(different multiplier for each abi as per the doc at https://developer.android.com/build/configure-apk-splits#configure-APK-versions), so I am assuming that when I switch to AAB, the next versionCode
will have to be larger than the largest versionCode
previously used.
Yes, that would be the case.