Reviving this but for those that are looking for something similar but for Android App Bundles.
As it's not as clear cut as when doing it for .apk.
For .aab's you need to:
- unpack the aab (its just a zip file)
- decode the AndroidManifest which is a binary proto message with protoc
- to decode you will need the .proto file found in the aapt2 tool
- alter the version code/version name of the decoded android manifest
- encode it again with protoc using the .proto files used in step 2
- pack the aab with zip, but be careful not to zip directories and to remove the path prefix that you might add unwillingly
- sign the zipped file with your store credentials, using jarsigner
- zipalign the signed zipped file
- rename the zipped, aligned and signed to the final .aab file
You can find these same steps in the following gist, with some of the work prepared before hand.
https://gist.github.com/Farious/e841ef85a8f4280e4f248ba8037ea2c0
I tried to avoid hardcoding anything and to bulletproof it, but it might not be yet.