The Android Software Bundle is Android’s new official publishing format, which makes it easier to develop and distribute your app. The Android App Bundle makes it easier to provide a fantastic experience in a smaller app, which can help you increase install success and decrease uninstalls. It’s simple to make the transition. To start profiting from a smaller app, you don’t need to modify your code. You’ll also benefit from modular app development and customised feature delivery once you’ve made the transition.
An App’s Structure
An Android app is compiled into an APK file in the usual procedure. APK files contain built Java code, XML layouts, native library binaries, and other resources compressed inside a ZIP file. To be able to support all Android devices, an APK must have the appropriate binaries for all CPU architectures. Furthermore, to accommodate varying screen sizes, app resources like as pictures and videos must be sent several times.
This entire portability method results in bloated APKs, which can include more than 75% of useless data. App bundles were created to address this issue.
In an ideal world, a user would download an APK that only contains necessary files. A phone with an ARM CPU, for example, should download an APK that only contains ARM binaries. Binaries for architectures like x86 and x86 64 should be avoided. Low-resolution pictures will suffice for a smart watch app.
A Novel Approach
To solve this problem, we tell the Android compiler to generate an AAB (app bundle) file rather than an APK.
The command above, unlike the traditional./gradlew app:assembleDebug, creates an app bundle.
An AAB file contains all of the data found in a standard APK build. It also contains extra meta data that may be used to find out how to make smaller APKs by cherry-picking pertinent files from its content.
We upload this AAB file to Google servers when it’s time to release a new version of our software on the Google Play store. Behind the scenes, Play servers use a programme called bundetool to generate tens, if not hundreds, of APK files, each customised to a single device.
We are allowed to utilise bundletool to build the final APKs because the Google Play store is not the sole distribution option for Android.
Build .aab file in IONIC
You’ll need “cordova-android” version 8.0.0 or later.
as usual, run ionic cordova build android —prod —release
./gradlew bundleRelease may be found in the /platforms/android folder. Instead of gradlew.bat, the file may be named gradlew.bat on Windows.
/platforms/android/app/build/outputs/bundle/release/app.aab is the location of the bundle. Sign this bundle the same way you would an APK before uploading it to the Play Store.
Is natively supported in cordova-android >= 8.1.0
— — — ionic cordova build android —prod —release
Before —packageType, notice the extra — — dashes. Cordova necessitates the first. Because there is another cli tool in between, the second one is necessary (ionic).
If you don’t want to utilise ionic, you may use cordova instead.
—packageType=bundle cordova build android —prod —release