History
Before Android App Bundles (AABs), the recommended way to reduce the file size of an APK, especially if you had large native-code libraries included (like FFmpeg or GeckoView), was to build multiple APKs.
Although it is better to build a single APK to support all your target devices whenever possible, that might result in a very large APK due to files supporting multiple screen densities or Application Binary Interfaces (ABIs). One way to reduce the size of your APK is to create multiple APKs that contain files for specific screen densities or ABIs.
There was support in the Gradle
build system to build multiple APKs. To publish these apps on Google Play, each would have its own version code. To do it correctly, each ABI (e.g. armabi-v7a, arm64-v8a, x86, x86_64) needs its own versionCode range.
The recommendation was to separate them by about 1000 numbers. App Builders uses this starting number for these ABIs
- ‘armeabi’: 1000
- ‘armeabi-v7a’: 2000
- ‘arm64-v8a’: 3000
- ‘mips’: 5000
- ‘mips64’: 6000
- ‘x86’: 8000
- ‘x86_64’: 9000
When it builds multiple APKs, then it builds for x86, armeabi-v7a, x86_64, arm64-v8a. So if you specify 5 as the versionCode in the AppBuilder with building multiple APKs, then you will get:
- armeabi-v7a at 2005
- arm64-v8a at 3005
- x86 at 8005
- x86_64 at 9005
Any time that you release a new version, there has to be a new APK with a versionCode higher than each of these ranges so that upgrades can happen on the device.
Android App Bundles
Now that we have AABs, Google Play can repackage an APK1 specific to the hardware platform and version of Android being downloaded to. There is no need for Multiple APKs.
So how do you switch from Multiple APKs to AABs? I don’t know for sure, but I have a reasonable guess. I suspect that if you use a versionCode larger than any of the existing multiple APKs that have been published to Google Play, then it should work. Unfortunately, the App Builders code has min=1 and max=1000 for version code. So I will have to talk to @richard about this. From Android documentation on versioning states:
Note: The greatest value Google Play allows for versionCode
is 2100000000.
As a work-around, you can set the versionCode in the .appDef manually (while SAB is closed) and then open the project in SAB and build it.
<version code="9006" name="11.0.4"/>
If you want, I can work with you to experiment with your project. Contact me at via email.
Chris Hubbard (chris_hubbard@sil.org)
Endnotes
1Technically, some versions of Android allow the app to be delivered as multiple APKs. So with older versions of Android it will be delivered as a single Single APK optimized to the ABI and screen size of the device. On newer versions of Android, it. will be delivered as multiple APKs.