Android devices come in different configurations and we need to cater for each variation in our app code and assets. At this point we can either have multiple apks or just one big fat apk which will cater for all devices across our device matrix. Android App Bundle or AAB is a publishing format for android apps. Think of it as all of our apps code and assets bundled together and handed over to Google Play, which then generates signed APKs for distribution. Play generates apks which are optimised for users devices resulting in smaller app size.
Considerations while moving to AABs
- Smaller optimised apps for users.
- Enables the option to use feature delivery which can further reduce app size.
- No code change required for switching to AAB format.
- Google play requires the app signing key in order to generate the APK. So we have to enrol into play app signing. The only call out here is that this is a permanent enrolment, there is no option to opt out of play app signing.
Note that AAB is just a publishing format and as such switching to AAB would not require and code change in the app. Although if we want to use feature delivery then that would require work around development and testing.
Impact when switching to AAB-
> Dev impact –
- No code change required
- Running the app on local devices work in a similar way. For running on a device directly from android studio the run configuration can be updated to APK from app bundle. Alternatively, you can download the bundleTool which will generate app from the bundle and install it on the device. Refer to this link on building the app from command Line : https://developer.android.com/studio/build/building-cmdline#build_bundle
> QA Impact
- No impact on QAs, as they will never see AABs and will still get the APK from play store or firebase on their devices.
> DevOps Impact
- If you have not yet enrolld for play app signing then you need to enroll into it. Generate upload key and keep it secure.
- If using firebase for app testing tracks you need to update grade script for firebase app distribution to specify the artefact type as aab. Refer — https://firebase.google.com/codelabs/appdistribution-app-bundles
- CI build plans need to be updated as well to use bundles. Use command sh gradlew :base:bundleVariant to generate a bundle of app.
- In our team we also need to push the apks on our automation servers, so we also had to set up plan for generation of app via bundle tool (https://github.com/google/bundletool).
Run following command to generate app from aab
bundletool build-apks — bundle=/MyApp/my_app.aab — output=/MyApp/my_app.apks
Starting from August 2021, Google Play has made it mandatory for all new apps to use AAB instead of APKs, but the existing apps can still use APKs,